closures questions
| From: | Lukas Kahwe Smith | Date: | Tue, 22 Jul 2008 11:04:03 +0000 |
| Subject: | closures questions | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-39172@lists.php.net to get a copy of this message | ||
Hi,
I am sending this on behalf of Kalle:
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.
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'));
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 data 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. regards, Lukas Kahwe Smith mls@pooteeweet.org