Re: Re: PHP 6.0 Wishlist
| From: | Zeev Suraski | Date: | Tue, 23 Aug 2005 19:01:23 +0000 |
| Subject: | Re: Re: PHP 6.0 Wishlist | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-18317@lists.php.net to get a copy of this message | ||
At 09:18 23/08/2005, Michael Walter wrote:
On 8/22/05, Stanislav Malyshev <stas@zend.com> wrote: MB>>> * Anonymous functions. The real stuff, not just some odd string MB>>> passed to create_function(). MB>> MB>>There were some others already asking for this, maybe we should at least MB>>give it a thought if it is doable at all, anybody? Just out of curiosity, what's bad in create_function and how "real" ones should be different? "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.
function adder($a) {return function($b) {return $a+$b;}} function index($i) {return function($a) {return $a[$i];}} I'm sure you can think of useful examples.Since when do we consider moving towards LISP a good thing? :) For those odd ends where you really need that, create_function() can do the job for you just as well (before anybody complains that it's cumbersome - GOOD, it's supposed to be, you're not supposed to be creating functions on the fly unless you absolutely have to). Zeev