> If it would create anonymous function compile-time, it would be a big > advantage to Wez's patch because then this function could be cached. > Thinking about this, maybe it is the reason enough to do this even if > it's not real closure.
On mulling this over a bit more, other than quick one-off callbacks (which would definitely benefit from avoiding compile on every request), one of the key reasons to use create_function() is actually to create dynamic functions: $fancyVer = create_function('', 'return "PHP " . phpversion();'); // could be optimized as: $fancyVer = create_function('', 'return "PHP ' . phpversion() .'";'); (the latter only calls phpversion() at declaration, not each time the lambda runs) Since phpversion() is available globally, this isn't a problem. But what happens if we want to use a variable, instead? $ver = phpversion(); $fancyVer = create_function('', "return 'PHP $ver';"); // this currently works ^ How would this be rewritten, though? $ver = phpversion(); $fancyVer = function () { return "PHP $ver"; }; where would $ver come from? the parent scope? the lambda's local scope? what if it's defined in both places? S -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php