Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15348 invoked from network); 13 Apr 2009 08:09:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2009 08:09:06 -0000 X-Host-Fingerprint: 66.183.89.177 unknown Received: from [66.183.89.177] ([66.183.89.177:26550] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/13-31755-023F2E94 for ; Mon, 13 Apr 2009 04:09:05 -0400 Message-ID: To: internals@lists.php.net Date: Mon, 13 Apr 2009 01:09:00 -0700 User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 References: <20090412025100.GA5493@klutometis.wikitex.org> <8B.71.31755.246E2E94@pb1.pair.com> <20090413080506.GB10458@klutometis.wikitex.org> In-Reply-To: <20090413080506.GB10458@klutometis.wikitex.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Posted-By: 66.183.89.177 Subject: Re: [PHP-DEV] Re: Closures and __FUNCTION__ From: frozenfire@thefrozenfire.com (Justin Martin) Well, it's a rather simple bit of logic. First, we define $foo and load it with NULL so that it is available for referencing. Next, in terms of program logic, we create a closure with a lexical ('use') variable of a reference to $foo, which is then assigned to $foo. Thus, the reference to $foo in the closure declaration now points to the closure itself. Recursion is always complicated :P Thanks, Justin Martin Peter Danenberg wrote: > Quoth Justin Martin on Pungenday, the 30th of Discord: >> Apparently it works as such: >> >> $foo = NULL; >> $foo = function($foo) use (&$foo) { >> ... >> } >> >> Still rather hackish, but better than globals I suppose? > > Heh; amazing. I'm not going to pretend to comprehend this hack; but > I'll use it, nonetheless.