Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97368 invoked from network); 19 May 2003 14:41:55 -0000 Received: from unknown (HELO carmine.bestweb.net) (209.94.102.73) by pb1.pair.com with SMTP; 19 May 2003 14:41:55 -0000 Received: from [192.168.1.102] (ip216-179-71-153.cust.bestweb.net [216.179.71.153]) by carmine.bestweb.net (Postfix) with ESMTP id 5D6E124F58 for ; Mon, 19 May 2003 09:41:50 -0500 (EST) To: internals@lists.php.net Content-Type: text/plain Organization: Message-ID: <1053350193.790.91.camel@hasele> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.4 Date: 19 May 2003 09:16:33 -0400 Content-Transfer-Encoding: 7bit Subject: Code References From: sterling@bumblebury.com (Sterling Hughes) 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.