> -----Original Message-----
> From: Stanislav Malyshev [mailto:s...@zend.com] 
> Sent: 19 January 2010 00:28
> To: 'PHP Internals'
> Subject: [PHP-DEV] function call chaining
> 
> Hi!
> 
> I wrote a small patch that enables this kind of syntax in PHP:
> 
> foo()();
> 
> What it means is that if foo() returns callable value (which 
> probably should be function name or closure) then it would be 
> called. Parameters and more than two sets of () work too.
> Of course, this is mostly useful for doing closures, and that 
> was primary drive for implementing it - to make working with 
> closures and especially function returning closures easier.
> What does not work currently is $foo->bar()() - since it is 
> surprisingly hard to tell parser it's not {$foo->bar}()() - 
> which of course is not what I want to do.
> 
> The patch is here: http://random-bits-of.info/funcfunc.diff
> 
> What do you think? If somebody has better idea btw - maybe 
> make something like {foo()}() - and make that work for any 
> expression inside {} - that might work too. So, what do you think?
> --
> Stanislav Malyshev, Zend Software Architect
> s...@zend.com   http://www.zend.com/
> (408)253-8829   MSN: s...@zend.com
> 
> --
> PHP Internals - PHP Runtime Development Mailing List To 
> unsubscribe, visit: http://www.php.net/unsub.php
> 

I've run into problems with 

$foo[1]();

If the closure attempts to change the value of $foo[1] then PHP
complains.
So was forced to assign to a temporary variable before hand.

$f = $foo[1];
$f();

I guessing foo()() could also suffer from the problem?

Jared 


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

Reply via email to