Re: PATCH: anonymous functions in PHP

From: Date: Mon, 19 Mar 2007 20:35:17 +0000
Subject: Re: PATCH: anonymous functions in PHP
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-28442@lists.php.net to get a copy of this message
On Mon, 2007-03-19 at 15:20 -0500, Richard Lynch wrote: > On Sun, March 18, 2007 6:41 pm, Wez Furlong wrote: > > We've been daydreaming about the ability to do something like this in > > PHP: > > > > $data = array("zoo", "orange", "car", "lemon", > > "apple"); > > usort($data, function($a, $b) { return strcmp($a, $b); }); > > var_dump($data); # data is sorted alphabetically > > I'd LOVE it if there was SOME difference between this and a normal > 'function' definition... > > I guess we're kind of stuck with 'create_function' being the mess that > it is. > > But perhaps something like 'temp_function' or 'local_function' or > 'lexical_closure' or something similar. Even 'horse' [*] would be > fine by me. > > I think it muddies things too much to have it just be 'function' with > no name after it. > > +1 A function with a name is no longer anonymous ;) Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.internals (#28442) next »