Re: optional type hinting enhancements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:
Nathan Rixham schreef:
Hi All,

preface: Having discussed at great length previously and probably
completely misnaming and thus misleading the conversation here goes again.

question: Would anybody else like to see, or feel the need for,
*optional* type hinting of variables and class properties in PHP?

examples (all optional, and syntax may differ):

class Example {
  private TypeHint $var;
}

Example $var = new Example();

in addition the ability to type hint primatives/scalars/[type object] in
the existing implementation:

function(bool $flag) {
}

function(object $flag) {
}


This would all be under the assumption and proviso that an
implementation would not break bc, have any markable perfomance hit, or
in any other way effect existing applications or new applications that
did not use the functionality (in the same way the existing type hinting
implementation doesn't)

Any +1's?

can I give a +1 for you making a request to start a RFC on the matter ...
I'm sure LKS will give you perms to set up one on wiki.php.net/rfc.

lukas, thoughts? [ini proposals coming in a minute, just diff'ing]

some of your ideas have merit, some maybe not, others are likely to be impossible
to implement from a performance technical POV.

either way, having a work-in-progress RFC for these ideas would give a solid point
of reference for discussion. all/any of your ideas have much more chance of
making inroads if implementation/BC/performance/syntax details/proposals are
properly documented.

agreed and thanks for the idea.

I think adhoc discussion via the mailing list leads generally nowhere with this
type of thing, there is too much noise and it's nigh on impossible to grok where
the status quo is at or what current the proposal might be.

noticed that one; which is a shame tbh; alas..

some of your points lean purely to making php more consistent, they may even
be self-evident (e.g. completion of things your able to typehint) but nonetheless
even that needs solid argumentation in order to win the minds of the guys that
will/may end up implementing it.

RFC is the way to go. I for one would gladly take time to read/review/comment, if
nothing else it's interesting.

interesting it is; it's a shame the evangalism list died a death [not sure why i see that as related, but i do]

actually thinking about it you might consider thinking in terms of a collection
of RFC's (your ideas cover quite a lot of ground/scope) in order to maintain tight
focus.


agreed, probably
- enhancing / completing existing type hinting
- single superclass which all objects extend
- optional type hinting for variables and class parameters
- optional type hinting for return types (mind you thats already rfc'd)
- additional magic method __cast (needs more thought)
- constructor overloading
- generics and templates [i jest]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux