Re: [RFC] Short Closures 2, aka auto-capture take 3
| From: | Björn Larsson via internals | Date: | Wed, 29 Jun 2022 18:09:34 +0000 |
| Subject: | Re: [RFC] Short Closures 2, aka auto-capture take 3 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118124@lists.php.net to get a copy of this message | ||
Den 2022-06-29 kl. 19:30, skrev Larry Garfield:
On Thu, Jun 9, 2022, at 11:34 AM, Larry Garfield wrote:Hi, Would it be an option to include a "Future scope" with the features: - Explicit capture that list only the variables to be captured by value or reference, nothing else. - Extending the traditional anonymous function with use(*) for capturing everything. Anyway, hope this passes for PHP 8.2! Regards //Björn LarssonLast 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-closureThe 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 theuse(*)syntax alternative, and why it wasn't, er, used. (Pun only sort of intended.) --Larry Garfield