Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43673 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 18467 invoked from network); 13 Apr 2009 08:20:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2009 08:20:04 -0000 X-Host-Fingerprint: 66.183.89.177 unknown Received: from [66.183.89.177] ([66.183.89.177:13334] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2E/A3-31755-3B5F2E94 for ; Mon, 13 Apr 2009 04:20:04 -0400 Message-ID: <2E.A3.31755.3B5F2E94@pb1.pair.com> To: internals@lists.php.net Date: Mon, 13 Apr 2009 01:20: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> <20090413081753.GC10458@klutometis.wikitex.org> In-Reply-To: <20090413081753.GC10458@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) I suppose it's an issue of cloning. Perhaps there's some difference between a cloned closure and a referenced closure? Thanks, Justin Martin Peter Danenberg wrote: >> First, we define $foo and load it with NULL so that it is available for >> referencing. > > It turns out loading $foo is superfluous; I can get away with just: > > $foo = function($foo) use (&$foo) { > $foo(); > } > >> 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. > > That much is clear; but why $foo is all of the sudden bound within the > closure when I use by reference (&$foo) as opposed to use by value > ($foo) is mysterious.