News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHP 10.1 Blog:
Y-Combinator in PHP
April 14, 2009 @ 11:17:19

New from the PHP 10.0 blog today is this look at trying to set up recursive closures in the upcoming PHP 5.3 release (it includes closures, but it doesn't look like this is possible). Instead, Stas suggests the Y combinator method as an alternative.

One of the ways to do it is to use Y combinator function, which allows, by application of dark magic and friendly spirits from other dimensions, to convert non-recursive code to recursive code. [...] Doing Y-combinator in PHP was attempted before (and here), but now I think it works better. It could be even nicer if PHP syntax allowed chaining function invocations - ($foo($bar))($baz) - but for now it doesn't.

His (less than ideal) first method throws in some variable variables and a separate factoral function and his second passes in a factoral value of itself to call itself the correct number of times.

0 comments voice your opinion now!
ycombinator closure php5 recursive


blog comments powered by Disqus

Similar Posts

Nexen.net: April 2006 PHP Usage Stats

DevShed: Working with Prepared Queries with PDO Objects in PHP 5

Johannes Schluter's Blog: PHP 5.3: Up to 30% performance win

Edin Kadribasic's Blog: First PHP build using the new compiler

Adam Trachtenberg's Blog: Dirty Secrets of OSCON 2006


Community Events

Don't see your event here?
Let us know!


conference interview laravel composer project community yii2 language introduction podcast php7 series part2 list symfony example opinion application framework api

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework