Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1702 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5986 invoked from network); 19 May 2003 14:47:54 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 19 May 2003 14:47:54 -0000 Received: (qmail 25267 invoked from network); 19 May 2003 14:47:39 -0000 Received: from localhost (HELO zeev-laptop.zend.com) (127.0.0.1) by localhost with SMTP; 19 May 2003 14:47:39 -0000 Reply-To: zeev@zend.com Message-ID: <5.1.0.14.2.20030519174656.049a9560@localhost> X-Sender: zeev@localhost X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Mon, 19 May 2003 17:47:20 +0300 To: Sterling Hughes Cc: internals@lists.php.net In-Reply-To: <1053350193.790.91.camel@hasele> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Code References From: zeev@zend.com (Zeev Suraski) References: <1053350193.790.91.camel@hasele> Anything that create_function() doesn't do? Zeev At 16:16 19/05/2003, Sterling Hughes wrote: >Hi, > >I figure I'll just throw this out into the wilderness, I want closures >and function pointers in PHP. In other words I want the ability to do: > >$var = function ($a, $b) { > return $a + $b; >}; > >And then $var can contain a code reference to the anonymous function. >Having code references is an infinitely useful feature in my experience, >and I know other people have some really cool uses of closures for >lightweight templating (with mod_perl.) [1] > >I'd also like function pointers, which are optimized callbacks of some >sort, so you can go: > >function my_compare($a, $b) { > if ($a > $b) return 1; > if ($a < $b) return -1; > return 0; >} > >sort($ar, ); > >And compare doesn't need to be resolved at runtime, but rather can be a >compile time feature. > >-Sterling > >[1] I say code references on purpose. This doesn't need to mean full >fledged closures, which are probably overkill (although, they would be >nice too ;) > >-- >"That stuff's easy compared to installing Horde" > - Alan Knowles, In response to my applause for creating a LALR > parser for PHP. > > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php