Re: closures questions
| From: | Lukas Kahwe Smith | Date: | Tue, 22 Jul 2008 11:07:07 +0000 |
| Subject: | Re: closures questions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-39173@lists.php.net to get a copy of this message | ||
On 22.07.2008, at 13:04, Lukas Kahwe Smith wrote:
1) Closures on class properties just don't work, the only way to do it is to do something like: $c = $a->b; $c(); Calling: $a->b(); will result in method A::B() does not exists.would be nice to get this fixed, but at worst it should be documented.
2) Closures can be defined as constants values because of its toString method: define('Closure', function(){ echo 'Test'; }); echo constant('Closure'); /* (string) Closure object */ 3) Since Closures have this toString method, but its not showing up in Reflection: Reflection::export(new ReflectionClass('Closure'));so do we even want the toString() method?
4) var_export() and Closures is useless, any call to var_export() like the example below will all be the same: $lambda = function() { echo 'Λ Lambda'; }; var_export($lambda); /* Closure::__set_state(array( )) */ Maybe it could return some relevant information for exporting the closure across datanot a huge biggy to me.
5) Its impossible to clone a closure using the cloning keyword: $a = function(){}; $b = clone $a; This makes it hard to make a copy of the closure because of objects always are passed by reference.I guess this is a draw back from the OO approach (rather than the original resource approach), but solvable? regards, Lukas Kahwe Smith mls@pooteeweet.org