Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-29 Thread Rowan Tommins
On 29/04/2021 10:25, Christian Schneider wrote: Without a keyword like "var" to declare it, I think most users would assume that an initialisation like "$foo=null;" at the top of their closure would make a variable local. This assumption by the users would be true as we are capturing by value,

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-29 Thread Christian Schneider
Am 29.04.2021 um 10:14 schrieb Rowan Tommins : > On 28/04/2021 23:00, Nuno Maduro wrote: > 3) All variables are captured, there is no local scope. This is effectively > what PHP's single-expression closures use. > > Option 3 is the easy option, and is currently "good enough" because it's rare >

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-29 Thread Nikita Popov
On Thu, Apr 29, 2021 at 12:00 AM Nuno Maduro wrote: > On Wed, 28 Apr 2021 at 15:31, Nikita Popov wrote: > >> On Wed, Mar 24, 2021 at 5:20 PM Larry Garfield >> wrote: >> >> > Greetings, Internalians. >> > >> > Some months back I proposed an RFC for short functions. >> > >> > https://wiki.php.net

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-29 Thread Rowan Tommins
On 28/04/2021 23:00, Nuno Maduro wrote: Concerning point 2: Developing some sort of static analysis that can infer what needs to be captured may be problematic. First, that won't be consistent with the way auto-capture currently works in PHP (one-line short closures). The question is, how do w

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-28 Thread Nuno Maduro
On Wed, 28 Apr 2021 at 15:31, Nikita Popov wrote: > On Wed, Mar 24, 2021 at 5:20 PM Larry Garfield > wrote: > > > Greetings, Internalians. > > > > Some months back I proposed an RFC for short functions. > > > > https://wiki.php.net/rfc/short-functions > > > > After some discussion, I put it on h

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-28 Thread Rowan Tommins
On 28/04/2021 15:31, Nikita Popov wrote: My suggestion would be to allow use(&$count) on fn(), which allows capturing certain variables by reference rather than by value. It might be rather confusing for the use block to sometimes mean "capture exactly these variables", and sometimes mean "c

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-28 Thread Nikita Popov
On Wed, Mar 24, 2021 at 5:20 PM Larry Garfield wrote: > Greetings, Internalians. > > Some months back I proposed an RFC for short functions. > > https://wiki.php.net/rfc/short-functions > > After some discussion, I put it on hold to ensure that it was compatible > with the other discussion floati

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-04-25 Thread Larry Garfield
On Wed, Mar 24, 2021, at 11:19 AM, Larry Garfield wrote: > Greetings, Internalians. > > Some months back I proposed an RFC for short functions. > > https://wiki.php.net/rfc/short-functions > > After some discussion, I put it on hold to ensure that it was > compatible with the other discussion f

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-28 Thread Rowan Tommins
On 25/03/2021 16:25, Larry Garfield wrote: So in conclusion, it seems the reasons closures weren't auto-capture always were: 1) Possible performance concerns that are no longer relevant. 2) Avoid surprise references. 3) Allow users to capture by value or by reference. I wasn't involved in th

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-28 Thread Aleksander Machniak
On 24.03.2021 17:19, Larry Garfield wrote: > 1) The updated short-functions RFC: https://wiki.php.net/rfc/short-functions > 2) A new RFC, code by Nuno, for auto-capturing multi-statement closures: > https://wiki.php.net/rfc/auto-capture-closure I'm not sure just the keyword (`fn`) should indicate

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-25 Thread Christian Schneider
Am 25.03.2021 um 17:25 schrieb Larry Garfield : > So in conclusion, it seems the reasons closures weren't auto-capture always > were: > > 1) Possible performance concerns that are no longer relevant. > 2) Avoid surprise references. > 3) Allow users to capture by value or by reference. > > Point

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-25 Thread Larry Garfield
On Thu, Mar 25, 2021, at 12:47 AM, Peter Stalman wrote: > On Wed, Mar 24, 2021 at 10:15 AM Chase Peeler wrote: > > > I guess my one question would be why we didn't support auto-capture when we > > first implemented anonymous functions, and if there was a reason, why does > > that no longer apply?

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Peter Stalman
On Wed, Mar 24, 2021 at 10:15 AM Chase Peeler wrote: > I guess my one question would be why we didn't support auto-capture when we > first implemented anonymous functions, and if there was a reason, why does > that no longer apply? > I believe this was the original discussion: https://externals

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Peter Stalman
On Wed, Mar 24, 2021 at 9:20 AM Larry Garfield wrote: > 1) The updated short-functions RFC: > https://wiki.php.net/rfc/short-functions > > 2) A new RFC, code by Nuno, for auto-capturing multi-statement closures: > https://wiki.php.net/rfc/auto-capture-closure > > These are separate RFCs and at th

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Deleu
On Wed, Mar 24, 2021, 17:20 Larry Garfield wrote: > Greetings, Internalians. > > Some months back I proposed an RFC for short functions. > > https://wiki.php.net/rfc/short-functions > > After some discussion, I put it on hold to ensure that it was compatible > with the other discussion floating a

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Rowan Tommins
On 24/03/2021 17:33, Christian Schneider wrote: My guess would be that it was seen as one of PHP's big strength that variables don't just leak into other contexts but that it has to be done explicitly. Now with arrow functions both the benefit of auto-capturing is bigger compared to the actual

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Chase Peeler
On Wed, Mar 24, 2021 at 1:34 PM Christian Schneider wrote: > Am 24.03.2021 um 18:15 schrieb Chase Peeler : > > I guess my one question would be why we didn't support auto-capture when > we > > first implemented anonymous functions, and if there was a reason, why > does > > that no longer apply? >

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Christian Schneider
Am 24.03.2021 um 18:15 schrieb Chase Peeler : > I guess my one question would be why we didn't support auto-capture when we > first implemented anonymous functions, and if there was a reason, why does > that no longer apply? My guess would be that it was seen as one of PHP's big strength that vari

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Chase Peeler
On Wed, Mar 24, 2021 at 1:02 PM Nikita Popov wrote: > On Wed, Mar 24, 2021 at 5:20 PM Larry Garfield > wrote: > > > Greetings, Internalians. > > > > Some months back I proposed an RFC for short functions. > > > > https://wiki.php.net/rfc/short-functions > > > > After some discussion, I put it on

Re: [PHP-DEV] [RFC] Auto-capture multi-line closures and short functions take 2

2021-03-24 Thread Nikita Popov
On Wed, Mar 24, 2021 at 5:20 PM Larry Garfield wrote: > Greetings, Internalians. > > Some months back I proposed an RFC for short functions. > > https://wiki.php.net/rfc/short-functions > > After some discussion, I put it on hold to ensure that it was compatible > with the other discussion floati