Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42476 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8647 invoked from network); 5 Jan 2009 02:20:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2009 02:20:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:58583] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 14/12-07052-46E61694 for ; Sun, 04 Jan 2009 21:20:22 -0500 Received: from MBOERGER-ZRH.corp.google.com (33-180.203-62.cust.bluewin.ch [62.203.180.33]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id 921E711F46D; Mon, 5 Jan 2009 03:20:17 +0100 (CET) Date: Mon, 5 Jan 2009 03:17:27 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <502088481.20090105031727@marcus-boerger.de> To: Larry Garfield CC: internals@lists.php.net In-Reply-To: <200901041505.25401.larry@garfieldtech.com> References: <272365052.20090104173130@marcus-boerger.de> <200901041505.25401.larry@garfieldtech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [RFC] Closures, Lambdas and use From: helly@php.net (Marcus Boerger) Hello Larry, Sunday, January 4, 2009, 10:05:25 PM, you wrote: > 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: And then what do we do with static? And besides how is: ...use (&$ref) different from: ...use &$ref; 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? > $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 Best regards, Marcus