On Wed, 11 Nov 2020 at 18:37, David Rodrigues <david.pro...@gmail.com> wrote:
>
> My suggestion is to reuse the keyword `as` to set a variable that will 
> represent its own
> closure. It is more flexible once that we could choose any name and reuse in 
> nested closures.
> It is pretty similar to how SQL works too.

Hi David,

That's a pretty reasonable suggestion, as it's less magic and less BC breaking.

I've updated the words of the RFC to that, but am even less sure of
how if/how that could be implemented...

Michael Voříšek wrote:
> by allowing to specify/capture the variable after the function is assigned:
>
> $f = function () use ($f) {...};

Unfortunately that's not how PHP works. The assignment to $f doesn't
happen until after the closure has been created. That's why currently
the variable can be passed in by reference....but that has the
undesirable problem that the RFC seeks to avoid.

cheers
Dan
Ack

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to