Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42477 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40280 invoked from network); 5 Jan 2009 04:10:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2009 04:10:45 -0000 Authentication-Results: pb1.pair.com header.from=larry@garfieldtech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=larry@garfieldtech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain garfieldtech.com from 76.96.62.32 cause and error) X-PHP-List-Original-Sender: larry@garfieldtech.com X-Host-Fingerprint: 76.96.62.32 qmta03.westchester.pa.mail.comcast.net Received: from [76.96.62.32] ([76.96.62.32:45361] helo=QMTA03.westchester.pa.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/67-07052-44881694 for ; Sun, 04 Jan 2009 23:10:45 -0500 Received: from OMTA09.westchester.pa.mail.comcast.net ([76.96.62.20]) by QMTA03.westchester.pa.mail.comcast.net with comcast id zRvm1a0050SCNGk53gAjAB; Mon, 05 Jan 2009 04:10:43 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA09.westchester.pa.mail.comcast.net with comcast id zgAi1a00R4trKQ83VgAjeA; Mon, 05 Jan 2009 04:10:43 +0000 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id A9D14D7A1F for ; Sun, 4 Jan 2009 22:10:41 -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 TtkPN9QsSK1E for ; Sun, 4 Jan 2009 22:10:41 -0600 (CST) Received: from luna.localnet (unknown [192.168.42.1]) by earth.ufp (Postfix) with ESMTPSA id 723F1D7A03 for ; Sun, 4 Jan 2009 22:10:41 -0600 (CST) To: internals@lists.php.net Date: Sun, 4 Jan 2009 22:10:39 -0600 User-Agent: KMail/1.10.3 (Linux/2.6.27-7-generic; KDE/4.1.3; i686; ; ) References: <272365052.20090104173130@marcus-boerger.de> <200901041505.25401.larry@garfieldtech.com> <502088481.20090105031727@marcus-boerger.de> In-Reply-To: <502088481.20090105031727@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200901042210.39136.larry@garfieldtech.com> Subject: Re: [PHP-DEV] [RFC] Closures, Lambdas and use From: larry@garfieldtech.com (Larry Garfield) On Sunday 04 January 2009 8:17:27 pm Marcus Boerger wrote: > Hello Larry, > > > > $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: > > And then what do we do with static? And besides how is: > ...use (&$ref) > different from: > ...use &$ref; I don't recall if statics were discussed previously, but the concept of a by- value static doesn't really make sense whereas it can for lexical or global variables. And the difference between use(&$var) and use &$var is that the latter looks like it SHOULD behave like the existing global keyword does, but can't because we need to support both by-value and by-reference. (Honestly I'm more likely to use by-value myself, I think.) So you'd have "global $foo" which is by-ref but "use $foo" which is by-value. That's not at all consistent or intuitive. Putting it in the function signature means it behaves exactly like the rest of the function signature with regards to by-value vs. by-reference behavior. > But maybe you want consistency by breaking nearly every PHP script ever > written? Or did I miss some Months and it is early April rather than early > January? Neither. At no point did I suggest removing the existing global keyword or altering its behavior. I simply said that if we're concerned about lexical variables having one syntax and global variables a different syntax right now, the solution is to allow global variables to use the same syntax as lexical (in addition to the current mechanism) not to make lexical use the same syntax as global (which is not flexible enough to handle the use cases lexical variables need in a consistent fashion). No, I didn't explicitly say to keep the existing syntax as well; I figured it was implicit. If that didn't make it through, I apologize. -- Larry Garfield larry@garfieldtech.com