Re: Closures and __FUNCTION__

From: Date: Mon, 13 Apr 2009 21:34:43 +0000
Subject: Re: Closures and __FUNCTION__
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-43686@lists.php.net to get a copy of this message
> function Y($F) { > $func = function ($f) { return $f($f); }; > return $func(function ($f) use($F) { > return $F(function ($x) use($f) { > $ff = $f($f); > return $ff($x); > }); > }); > } That's interesting; I should be able to implement tail-recursion in a similar fashion using, say, trampolines,[1] shouldn't I? > On the other hand, we may want to add some way to refer to the > closure currently being run. We should have this information, so it > should not be too hard to do. That would be great; we could even do some benchmarking against the Y-combinator (which I've always loved, but never used). Footnotes: [1] http://en.wikipedia.org/wiki/Tail_recursion#Implementation_methods

« previous php.internals (#43686) next »