Re: T_AS in closures
| From: | Nikita Popov | Date: | Wed, 05 Mar 2014 21:38:54 +0000 |
| Subject: | Re: T_AS in closures | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-72948@lists.php.net to get a copy of this message | ||
On Wed, Mar 5, 2014 at 10:28 PM, Andrey Andreev <narf@devilix.net> wrote:
> Hi,
>
> I was clicking on bugs.php.net/random today and I came across #54888,
> which is a feature request for the following syntax:
>
> $foo = 'whatever';
> $bar = function() use ($foo as $baz) { /* use $baz here */ };
>
> https://bugs.php.net/bug.php?id=54888
>
> I don't know if other languages have it, but it seems nice and
> considering how much developers prefer foreach() over other loops
> because it allows them to "rename" the variable, I'm sure people would
> love it.
>
> Has this been discussed before? What are your opinions on it?
>
> Regards,
> Andrey Andreev.
>
There has been an RFC for this: https://wiki.php.net/rfc/useas
IIRC the RFC was withdrawn because the reception was not very positive. You
might want to have a look at the discussion, see
http://markmail.org/message/q53myujswaesca2u
and
http://markmail.org/message/nrptrylgkarqrpxk.
Nikita