Zeev, On 8/23/05, Zeev Suraski <[EMAIL PROTECTED]> wrote: > >"Real" anonymous functions (as in, closures) should be able to capture > >variables from its lexical environment, e.g.: > > create_function() accepts a string, and that string is constructed with > full access to the lexical scope of the creating function, so I'm not > exactly sure how it's different. My ML/LISP memory fails me.
It certainly does not appear to be that way in PHP 4, in the supposedly equivalent snippet: function adder($a) {return create_function('$b', 'return $a+$b;');} ..$a is not accessible from inside the anonymous function. This is the reason Stanislav put the content of $a into the code string (and probably the reason he chose adder() instead of index() for his "counter-example" ;). > Since when do we consider moving towards LISP a good thing? :) FWIW, I'm merely explaining the problem, not giving any opinion (too afraid of Derick ;). Cheers, Michael PS: Common Lisps get the garbage collection right, though! ;) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php