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