RE: [PHP-DEV] PATCH: anonymous functions in PHP

From: Date: Mon, 19 Mar 2007 21:59:13 +0000
Subject: RE: [PHP-DEV] PATCH: anonymous functions in PHP
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to internals+get-28460@lists.php.net to get a copy of this message
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

« previous php.internals (#28460) next »