Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43665 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98094 invoked from network); 12 Apr 2009 02:51:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Apr 2009 02:51:03 -0000 Authentication-Results: pb1.pair.com header.from=pcd@roxygen.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=pcd@roxygen.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain roxygen.org from 72.51.35.14 cause and error) X-PHP-List-Original-Sender: pcd@roxygen.org X-Host-Fingerprint: 72.51.35.14 klutometis.wikitex.org Linux 2.6 Received: from [72.51.35.14] ([72.51.35.14:60824] helo=klutometis.wikitex.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/A6-59068-61751E94 for ; Sat, 11 Apr 2009 22:51:03 -0400 Received: from klutometis.wikitex.org (localhost.localdomain [127.0.0.1]) by klutometis.wikitex.org (8.13.1/8.13.1) with ESMTP id n3C2p0Uh005589 for ; Sat, 11 Apr 2009 21:51:00 -0500 Received: (from pcdanenb@localhost) by klutometis.wikitex.org (8.13.1/8.13.1/Submit) id n3C2p0kt005588 for internals@lists.php.net; Sat, 11 Apr 2009 21:51:00 -0500 Date: Sat, 11 Apr 2009 21:51:00 -0500 To: internals@lists.php.net Message-ID: <20090412025100.GA5493@klutometis.wikitex.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Fnord: I have seen the fnords. User-Agent: Mutt/1.5.16 (2007-06-11) Subject: Closures and __FUNCTION__ From: pcd@roxygen.org (Peter Danenberg) The original anonymous functions patch[1] contained support for __FUNCTION__ as a recursion mechanism in closures, such that I should be able to do something like this: $factorial = function($n) { if ($n == 1) return 1; else return $n * call_user_func(__FUNCTION__, $n - 1); }; print $factorial(3); // => 6 It fails with a warning, though: Warning: call_user_func() expects parameter 1 to be a valid callback, function '{closure}' not found or invalid function name Is there another recursion mechanism for closures besides something like the $GLOBALS['factorial'] hack? Footnotes: [1] http://marc.info/?l=php-internals&m=119995982228453&w=2