Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:39074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17232 invoked from network); 18 Jul 2008 06:10:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2008 06:10:47 -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.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:45882] helo=QMTA05.emeryville.ca.mail.comcast.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A5/E0-31728-6E330884 for ; Fri, 18 Jul 2008 02:10:47 -0400 Received: from OMTA10.emeryville.ca.mail.comcast.net ([76.96.30.28]) by QMTA05.emeryville.ca.mail.comcast.net with comcast id r3F01Z0060cQ2SLA5JAknZ; Fri, 18 Jul 2008 06:10:44 +0000 Received: from earth.ufp ([24.13.255.226]) by OMTA10.emeryville.ca.mail.comcast.net with comcast id rJAf1Z0094trKQ88WJAgay; Fri, 18 Jul 2008 06:10:40 +0000 X-Authority-Analysis: v=1.0 c=1 a=gp10tHn8qhYA:10 a=fpdT-6tg-ioA:10 a=jGgC2rv2sd-WuRw2SWkA:9 a=JubBoR6cmwWKNPoFbB4A:9 a=GdRbzSL4TmvxzsSoDnsA:7 a=q29ODDRbkBRDMZZ_S303u8ZKNh8A:4 a=FHBbIDN7CdwA:10 a=LY0hPdMaydYA:10 Received: from localhost (localhost [127.0.0.1]) by earth.ufp (Postfix) with ESMTP id E8377D8855 for ; Fri, 18 Jul 2008 01:10:42 -0500 (CDT) Received: from earth.ufp ([127.0.0.1]) by localhost (earth.ufp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IquXwFzw7iZA for ; Fri, 18 Jul 2008 01:10:41 -0500 (CDT) Received: from luna.local (unknown [192.168.42.104]) by earth.ufp (Postfix) with ESMTP id 92659D8854 for ; Fri, 18 Jul 2008 01:10:40 -0500 (CDT) To: internals@lists.php.net Date: Fri, 18 Jul 2008 01:10:38 -0500 User-Agent: KMail/1.9.9 References: <54FF091B-A4BE-4C3E-9783-D2DE93D6AF31@at.wakwak.com> In-Reply-To: <54FF091B-A4BE-4C3E-9783-D2DE93D6AF31@at.wakwak.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <200807180110.38919.larry@garfieldtech.com> Subject: Re: [PHP-DEV] [PATCH] Allow use($var..) statement ubiquitously From: larry@garfieldtech.com (Larry Garfield) On Thursday 17 July 2008 6:23:31 pm Moriyoshi Koizumi wrote: > Hi, > > Attached are the patches that allow the "use" statement that was > introduced with closures to appear within every function statement > except method definitions. I think this feature is a good addition > because it resolves inconsistency between closures and unticked > functions. In a nutshell, > > function foo() use (&$some_globals) { > echo $some_globals; > } > ?> > > is equivalent to > > function foo() { > global $some_globals; > echo $some_globals; > } > ?> > > While, > > function bar() { > $some_local_var = ''; > function fubar() use (&$some_local_var) { > echo $some_local_var; > } > } > ?> > > and > > function bar() { > function fubar() { > global $some_local_var; > echo $some_local_var; > } > } > ?> > > are of course not the same. Which is why I am not a fan of this syntax as proposed. You're using the same keyword to mean two different but very very close things. That's very confusing. It also means that you cannot take a global by value in a closure. Earlier the following was proposed: function foo($a, &$b) global ($c, &$d) { } $bar = new function($a, &$b) use ($c, &$d) global ($e, &$f) { }; Which I think is much more self-explanatory, accomplishes the same goal, and still does not introduce any new keywords. (I still think "lexical" is better than "use", and safe, but whatev. ) -- Larry Garfield larry@garfieldtech.com