>>> $foo = {
>>>   'bar' : function(){
>>>      echo 'baz';
>>>   }
>>> };
>>> 
>>> $foo->bar();
>> 
>> I guess it's not yet too late to surpass Perl in the front of obscurity...
> 
> Since the stuff to the right of the assignment operator (`:` in this case) is 
> valid PHP, I don't see why this wouldn't be allowed if we adopt the {} 
> syntax. It's not much different from this, which is currently valid:
> 
> $foo = (object)array(
>  'bar' => function () {
>    echo 'baz';
>  }
> };

Matthew pointed out to me (on IRC) that this actually doesn't work in current 
PHP (you can't call an object property as a closure without one of the proxy 
functions like call_user_function_array()). My mistake.

Note that this shouldn't affect the RFC, and this behaviour should be addressed 
as a separate issue if people think it should work (FWIW, I do obviously think 
this should work, but that's a separate thread, please).

S
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to