Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33668 invoked from network); 13 Apr 2012 08:20:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 08:20:11 -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:42722] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/36-01254-9B1E78F4 for ; Fri, 13 Apr 2012 04:20:10 -0400 Received: by yhfq11 with SMTP id q11so1680715yhf.29 for ; Fri, 13 Apr 2012 01:20:07 -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=dtZXKNbVe99CRkcqb45H0aJEKty0YcNiDyANCk1YDuk=; b=y6GVyQIPhuz9d2attPxT5lSsl84dKu6skFkvN3WaWbpggZcleP702LAXEx3Mtx0SNs qIwE5nL43wCYW3plBPDo3+/uvoU0Fz7ZvBSvMB/9oyApzW9cyq52PKCSeYkAgWDpPM0z 8TDl2EWh3e0bLAsPQDxf4jTweizkyfGRnHZqaujU6QJRfz6ElZ0hnd3OIc41LK45eR3e hc1HF1QNJ6hpAxiSr7vM+YiXP+wVqztS4OHFyu4jKLwD+uhYPURhRcjGquo5auhdM6S3 RF86LEDgGE1Jz/LigkIsVkW+oOnJHKBHZbpniNCrwUKJTMKoF2oEuPh5gPmaIc31uUZE zm6w== Received: by 10.236.170.198 with SMTP id p46mr801935yhl.63.1334305207283; Fri, 13 Apr 2012 01:20:07 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.146.86.14 with HTTP; Fri, 13 Apr 2012 01:19:27 -0700 (PDT) In-Reply-To: <4F87DF77.7040608@mail.by> References: <4F87DF77.7040608@mail.by> Date: Fri, 13 Apr 2012 17:19:27 +0900 X-Google-Sender-Auth: X6LTUOttNmY2WR_6ra8e4tWNeu8 Message-ID: To: Verbitsky Alexander Cc: 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 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 decla= ration, >> 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 keywo= rd > 'use' is not necessary and i would have removed it. If you need different > name of variable maybe you need anonymous function. > You might be used to other language's scoping, but this is the way PHP works. 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; } I would rather have this. function FUNC($a, $b, $c) uses ($d, $e, $f) {} Then it would be consistent with anonymous function. There are methods, so we should be careful though. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net