We could compile the anonymous function at compile-time but leave
placeholders which need to be "fixed-up" when at run-time the actual
closure is created. For this purpose we could introduce a new magical
variables $_SCOPE["var"] which references the current $var during fixup
time.
So here's an example:
$var = php_version();
$fancyVer = function () { return "PHP $_SCOPE['ver']; };
So what this does is compile the "anonymous function" at compile-time,
but when this line is executed (note, this line of code should also be
reached during execution), then we do the fix-up for $_SCOPE variables.
Regular variables remain what they would in create_function(). Fix-up
time would be faster than compiling the code.
Thoughts?
Andi
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php