Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42475 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72333 invoked from network); 4 Jan 2009 21:05:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2009 21:05:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.30.48 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.30.48 qmta05.emeryville.ca.mail.comcast.net Received: from [76.96.30.48] ([76.96.30.48:53299] helo=QMTA05.emeryville.ca.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/5F-07052-A9421694 for ; Sun, 04 Jan 2009 16:05:31 -0500 Received: from OMTA05.emeryville.ca.mail.comcast.net ([76.96.30.43]) by QMTA05.emeryville.ca.mail.comcast.net with comcast id zTsk1a0070vp7WLA5Z5VbJ; Sun, 04 Jan 2009 21:05:29 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA05.emeryville.ca.mail.comcast.net with comcast id zZ5U1a0054trKQ88RZ5Up8; Sun, 04 Jan 2009 21:05:29 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id AEA8BD7A1F for ; Sun, 4 Jan 2009 15:05:26 -0600 (CST) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v0vriYgxWWpO for ; Sun, 4 Jan 2009 15:05:26 -0600 (CST) Received: from luna.localnet (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTPSA id 65E8ED7A16 for ; Sun, 4 Jan 2009 15:05:26 -0600 (CST) To: internals@lists.php.net Date: Sun, 4 Jan 2009 15:05:25 -0600 User-Agent: KMail/1.10.3 (Linux/2.6.27-7-generic; KDE/4.1.3; i686; ; ) References: <272365052.20090104173130@marcus-boerger.de> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200901041505.25401.larry@garfieldtech.com> Subject: Re: [PHP-DEV] [RFC] Closures, Lambdas and use From: larry@garfieldtech.com (Larry Garfield) On Sunday 04 January 2009 10:45:30 am Sebastian Bergmann wrote: > Marcus Boerger schrieb: > > $f = function() { use $x; } > > +1 for consistency. +1 for consistency as well, which is why, as I recall, that syntax was rejected. $f = function() { global $x; // By reference. use $y; // By value or by reference? } If $y is by reference by default there was no obvious way to make it by value. If by value, then it is inconsistent with the behavior of global, which is by reference. It was determined that we definitely needed to be able to allow both by value and by reference. $f = function() use ($y, &$z) { global $x; // By reference } $y is clearly by value, and $z clearly by reference, as that parallels the way function parameters work right next to the lexical variables. The way to increase consistency would be to allow the opposite: $f = function($a, &$b) use ($y, &$z) global ($x, &$w) { } $x is pulled from global scope by value. $w is pulled from global scope by reference. $y is pulled from lexical scope by value. $z is pulled from lexical scope by reference. $a is pulled from calling scope by value. $b is pulled from calling scope by reference. Right now we have everything there except the global param list. I don't know if we want to bother adding that in 5.3 at this point (as it would be a syntax/feature change), but IMO that is the best way to improve consistency while getting a little extra functionality (global by value) at the same time. -- Larry Garfield larry@garfieldtech.com