Re: [RFC] Alternative "use" syntax for Closures
| From: | Ben Ramsey | Date: | Mon, 17 Jun 2019 19:36:03 +0000 |
| Subject: | Re: [RFC] Alternative "use" syntax for Closures | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105967@lists.php.net to get a copy of this message | ||
> On Jun 17, 2019, at 12:50, Mark Randall <markyr@gmail.com> wrote:
>
> On 17/06/2019 15:40, Ben Ramsey wrote:
>>> Where "use (...)" would auto-capture all of the used variables in a similar
>>> manner to short closures, that would certainly save a bit of time.
>
>> Would this mean that all variables in the “parent" are now available in the
>> “child?” This seems like it could result in some unexpected surprises as scope “leaks”
>> across these boundaries.
>
> Just the ones which are used, like short closures.
I see. So it would figure it out based on scope and only use those variables that are explicitly
used. This is somewhat similar to the way $this works in closures today. I think I would be okay
with this functionality, especially if this is how short closures work.
-Ben
Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc
Attachment: [application/pgp-signature] Message signed with OpenPGP signature.asc