I have to agree with Richard as a user-land developer. It looks nice, but
knowing how people can twist things I don't think I would like this feature
get implemented. It just add stuff that is crazy to debug.

Consider someone adds a property and initializes a user-land object. That
object has other object properties with are created and the chain goes on
for 2-3 more levels. Dealing with a __construct or a dedicated init method
is far easier and at least predictable stuff. I imagine someone initiating
objects at property declaration and then somewhere in the code assigning
the data they want the object to work with instead of just passing it in to
the constructor or calling a dedicated method to do that right after
creating an object.

19 апреля 2012 г. 0:31 пользователь Richard Lynch <c...@l-i-e.com> написал:

> On Sun, April 15, 2012 5:47 pm, Simon Schick wrote:
> > Just to add a random thought ....
> > When do you expect this code to be executed?
> >
> > class Foo {
> >     static public $foo = new StdClass();
> > }
>
> I may be too late to this party, but...
>
> For what it's worth, if the non-scalar initialization in class
> definition were to be implemented, I, the naive PHP developer, would
> expect the implementation to execute the new StdClass() exactly once
> (either at compile time or on the instantiation of the first instance)
> and Foo::$foo or whatever it is would be static in the sense that the
> same instance of a stdClass would be shared by all Foo instances.
>
> I'm with Stas on this one though.
>
> Yes, it would be nifty syntactic sugar, and I used to yearn for it.
>
> But complex initializations in the constructor is something I've grown
> used to, and now appreciate as a Feature.
>
> Trying to find all the little bits and pieces of non-scalar
> initializations up and down the chain of a complex class hierarchy is
> already difficult enough.
>
> Tossing in a bunch more places it can happen is Not Good (tm).
>
> --
> brain cancer update:
> http://richardlynch.blogspot.com/search/label/brain%20tumor
> Donate:
>
> https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to