Re: Code References

From: Date: Mon, 19 May 2003 14:47:20 +0000
Subject: Re: Code References
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-1702@lists.php.net to get a copy of this message
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, <my_compare>); 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


« previous php.internals (#1702) next »