Re: [RFC] Draft - Closure self reference
| From: | Sara Golemon | Date: | Fri, 20 Nov 2020 17:47:25 +0000 |
| Subject: | Re: [RFC] Draft - Closure self reference | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112264@lists.php.net to get a copy of this message | ||
On Fri, Nov 20, 2020 at 11:40 AM Larry Garfield <larry@garfieldtech.com>
wrote:
> > (5) function $lambda(... $args): returnType use ($captures...) {}
> >
> > To be honest, as I typed what came to mind, I ended up preferring this
> last
> > option.
>
> I kind of like that option, too.
Agreed that this has some attractiveness to it.
What does returning by reference look like in that world though?
$fn = function &$lambda($args...) {...};
Capturing lambda by reference doesn't make sense when you've just declared
the var, but it looks confusing AF.
$fn = function $lambda&($args...) {...};
Hello PERL...
> The main question in my mind is whether that means the same variable is
> used internally and externally or not.
>
The prototype I wrote in my brain for this would have $lambda exclusively
within the closure's scope, not leaked to the declaring scope. I think I
prefer that even though it looks a bit odd to have a name on a function
that's not accessible from where it's defined.
TL;DR - Still a little confusing.
-Sara