Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59872 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56723 invoked from network); 13 Apr 2012 10:36:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 10:36:47 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:42890] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/04-35770-EB1088F4 for ; Fri, 13 Apr 2012 06:36:46 -0400 Received: by yhfq11 with SMTP id q11so1707441yhf.29 for ; Fri, 13 Apr 2012 03:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=c4/I3L2VCA7McB/HD4NBpp3OGRbz0UB7HmQk9ibWtaE=; b=YzpThSzJizzJ4AsQpYlYdb0a+CnsFi3kuBIV1inVik7h1BIkcm/YWv4rIftgwjNJH/ KLX2VCaYocxMp5q3CZV/cPnRHGpIorcbnzytaTedOxy39IRsjQc8osMAdIEDhmYY0bxA 2b38nCH1NHXhgNzcYdEhkk0HYOClYrkXMJ0nGYnC5N00IXE/+Y/woaCP5Qc2OgzEQx4m 9OseKDDDbBTIuZ0ZYom+YfoxuxNd8jcssEaF0Hz7dcyUMPiARHABungO0jpkBtBIDNlg YAN0IV+a9dtMNqCfvX6+VHg5ApiuVjAs4mHnkrlNCmb6TUc4iUwgfq2SeAn6Z37cs1T6 hkcg== Received: by 10.101.3.18 with SMTP id f18mr340075ani.31.1334313403784; Fri, 13 Apr 2012 03:36:43 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.146.86.14 with HTTP; Fri, 13 Apr 2012 03:36:02 -0700 (PDT) In-Reply-To: References: <4F87DF77.7040608@mail.by> Date: Fri, 13 Apr 2012 19:36:02 +0900 X-Google-Sender-Auth: HMOHXOvvKTEKySKPqrhiYJnmVvg Message-ID: To: Laruence Cc: Verbitsky Alexander , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Allow "use( $longname as $alias)" syntax for closures declaration From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi, 2012/4/13 Laruence : > On Fri, Apr 13, 2012 at 4:19 PM, Yasuo Ohgaki wrote: >> Hi, >> >> 2012/4/13 Verbitsky Alexander : >>> On 04/12/2012 06:38 PM, Laruence wrote: >>>> >>>> Hi: >>>> =A0 =A0 =A0I have made a RFC to allow user use T_AS in the closure dec= laration, >>>> like: >>>> >>>> =A0 =A0 =A0function () use($long as $l,&$long as $r) { >>>> >>>> =A0 =A0 =A0} >>>> >>>> =A0 =A0 =A0here is the RFC: https://wiki.php.net/rfc/useas >>>> >>>> =A0 =A0 =A0any ideas? =A0thanks >>>> >>> Closure is a functional literal that can pull with itself all variables >>> visible in current scope where it was created. For my opinion using key= word >>> 'use' is not necessary and i would have removed it. If you need differe= nt >>> name of variable maybe you need anonymous function. >>> >> >> You might be used to other language's scoping, but >> this is the way PHP works. > closure was not the way PHP works. =A0but now, =A0it has be introduced in= PHP >> >> Named function cannot do this, but anyway >> function FUNC($a, $b, $c) uses ($d, $e, $f) {} >> is like >> function FUNC($a, $b, $c) { global $d, $e, $f; } > > they do are different, =A0previous is a lexical variable. =A0that means i= t > equal to the value when the closure is created. > > the latter is the value when it was called. Thanks for correction. I should have mentioned that. It's only similar that these are importing outside vars into current scope. Importing is the same, but scope is not. I wander if there are any good named function usage that imports current scope vars. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net