Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59864 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42468 invoked from network); 13 Apr 2012 09:21:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 09:21:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:34730] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/21-35770-020F78F4 for ; Fri, 13 Apr 2012 05:21:37 -0400 Received: by vcbfo14 with SMTP id fo14so2295041vcb.29 for ; Fri, 13 Apr 2012 02:21:34 -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=/Lu92S3YFyEqmNBA87ALkYqzC1isvtiQo5qE6rJTZKg=; b=l6lhh8V0+YO8VvIFw5nm0nQbuXjhhCxOdx8+xE2qMsH9J615TmkA381lLUIkLsrpB+ rb+pdenBErAtFj7JRvJ8aqUe1YeK8L29Q53zkCMUYPR4HVLtgOL0afdmKuqOatokl4K1 B+KwtTl8uvkTQt8OfUaL3+AoJ8d5t6WA07Tafyj8fdeK8yR6Mt4BTptRyDitn3sih8yN I4xvGaDIW22ybxD8l3xemRVzLF22Fz0bNsMzkHLYKqC/wqT1PS9/T/I1BYcMm7RHX0uV WvTgSnP9QqHDyiTUjyIOlz+rYJDxm5rwQQMXp4OGJBfu/9BntsFsSm8XNcf1oiyfWhVm CnrQ== Received: by 10.220.156.72 with SMTP id v8mr435621vcw.45.1334308894410; Fri, 13 Apr 2012 02:21:34 -0700 (PDT) MIME-Version: 1.0 Sender: laruence@gmail.com Received: by 10.220.18.194 with HTTP; Fri, 13 Apr 2012 02:21:14 -0700 (PDT) In-Reply-To: References: <4F87DF77.7040608@mail.by> Date: Fri, 13 Apr 2012 17:21:14 +0800 X-Google-Sender-Auth: FKRkemA8D9jYm7LjNpJzMDan5dQ Message-ID: To: Yasuo Ohgaki Cc: Verbitsky Alexander , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Allow "use( $longname as $alias)" syntax for closures declaration From: laruence@php.net (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: >>> =C2=A0 =C2=A0 =C2=A0I have made a RFC to allow user use T_AS in the clo= sure declaration, >>> like: >>> >>> =C2=A0 =C2=A0 =C2=A0function () use($long as $l,&$long as $r) { >>> >>> =C2=A0 =C2=A0 =C2=A0} >>> >>> =C2=A0 =C2=A0 =C2=A0here is the RFC: https://wiki.php.net/rfc/useas >>> >>> =C2=A0 =C2=A0 =C2=A0any ideas? =C2=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 keyw= ord >> 'use' is not necessary and i would have removed it. If you need differen= t >> 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. but now, it 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, previous is a lexical variable. that means it equal to the value when the closure is created. the latter is the value when it was called. thanks > > 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 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/