Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118124 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92113 invoked from network); 29 Jun 2022 16:18:14 -0000 Received: from unknown (HELO localhost.localdomain) (76.75.200.58) by pb1.pair.com with SMTP; 29 Jun 2022 16:18:14 -0000 To: internals@lists.php.net,Larry Garfield Message-ID: <7f9a762d-65d9-f2eb-08c4-0068be5ded96@telia.com> Date: Wed, 29 Jun 2022 20:09:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-GB References: <2b35605f-8da8-46b1-aec3-00bd1bfe47fd@www.fastmail.com> <84eb5551-cfaa-42e6-9a74-ae229d5e269c@www.fastmail.com> Reply-To: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= In-Reply-To: <84eb5551-cfaa-42e6-9a74-ae229d5e269c@www.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 213.64.245.126 Subject: Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3 From: internals@lists.php.net ("Björn Larsson via internals") Den 2022-06-29 kl. 19:30, skrev Larry Garfield: > 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 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 Larsson