Re: Call closure stored as object property directly without use of temporary variable
| From: | Adam Jon Richardson | Date: | Sat, 08 Dec 2012 23:12:23 +0000 |
| Subject: | Re: Call closure stored as object property directly without use of temporary variable | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-64203@lists.php.net to get a copy of this message | ||
On Sat, Dec 8, 2012 at 5:36 PM, Steve Clay <steve@mrclay.org> wrote:
> On 12/8/12 4:48 PM, Adam Jon Richardson wrote:
>
>> call closures that are stored as object properties directly without having
>> to make use of a temporary variable.
>>
> ...
>
> $o = new stdClass();
>> $o->func = function(){
>> return 'Yes!';
>> };
>> $o->func();
>>
>
> The following expression avoids PHP's dilemma of distinguishing
> prop/method, but fails because you can't execute an expression:
>
> ($o->func)();
>
I actually tried that very technique before remembering the limitation :)
Interesting idea.
Adam