Re: [RFC] Short Closures 2, aka auto-capture take 3
| From: | Larry Garfield | Date: | Wed, 29 Jun 2022 17:30:11 +0000 |
| Subject: | Re: [RFC] Short Closures 2, aka auto-capture take 3 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118123@lists.php.net to get a copy of this message | ||
On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote:
> Last year, Nuno Maduro and I put together an RFC for combining the
> multi-line capabilities of long-closures with the auto-capture
> compactness of short-closures. That RFC didn't fully go to completion
> due to concerns over the performance impact, which Nuno and I didn't
> have bandwidth to resolve.
>
> Arnaud Le Blanc has now picked up the flag with an improved
> implementation that includes benchmarks showing an effectively net-zero
> performance impact, aka, good news as it avoids over-capturing.
>
> The RFC has therefore been overhauled accordingly and is now ready for
> consideration.
>
> https://wiki.php.net/rfc/auto-capture-closure
The conversation has died down, so we'll be opening the vote for this tomorrow.
Two changes of note since the discussion started:
* The option to mix explicit capture and implicit capture has been removed as too
confusing/unpredictable. Either trust the engine to capture the right things (the new syntax
proposed here) or explicitly list everything (the existing syntax we've had since 5.3.)
* We added a section discussing the
use(*) syntax alternative, and why it wasn't,
er, used. (Pun only sort of intended.)
--Larry Garfield