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

2021-03-28 Thread Larry Garfield
On Sun, Mar 28, 2021, at 7:34 AM, Deleu wrote: > > > > but then we can bring up the side running RFC from > > Larry which proposes to make the same short syntax available for other > > function declarations, how would this work then with this mindset of > > `fn` meaning auto capture? Does that

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

2021-03-28 Thread Mike Schinkel
> On Mar 28, 2021, at 8:04 AM, Kalle Sommer Nielsen wrote: > > Den søn. 28. mar. 2021 kl. 14.30 skrev Deleu : >> >> The fact that short closure is inconsistent with the rest of PHP is a done >> deal since the voting passed prior to 7.4 release. Unless there's a >> follow-up to deprecate

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

2021-03-28 Thread Deleu
> > but then we can bring up the side running RFC from > Larry which proposes to make the same short syntax available for other > function declarations, how would this work then with this mindset of > `fn` meaning auto capture? Does that mean a procedural function > declared with `fn` will now

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

2021-03-28 Thread Kalle Sommer Nielsen
Den søn. 28. mar. 2021 kl. 14.30 skrev Deleu : > > The fact that short closure is inconsistent with the rest of PHP is a done > deal since the voting passed prior to 7.4 release. Unless there's a follow-up > to deprecate the 7.4 short closure auto capture without `auto` keyword and > make it

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

2021-03-28 Thread Deleu
The fact that short closure is inconsistent with the rest of PHP is a done deal since the voting passed prior to 7.4 release. Unless there's a follow-up to deprecate the 7.4 short closure auto capture without `auto` keyword and make it look like PHP can't make up it's mind, I feel that your

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

2021-03-28 Thread Andreas Leathley
On 27.03.21 17:05, Rowan Tommins wrote: My biggest concern with automatic capture is the potential for *accidentally* capturing variables - that is, intending to introduce a local variable inside the closure, but capturing a variable from the outer scope that happens to have the same name. This

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

2021-03-28 Thread Kalle Sommer Nielsen
Den søn. 28. mar. 2021 kl. 13.02 skrev Deleu : > > This would lead to inconsistent behavior in the language when short closures > auto capture without the auto keyword while multi statements closure doesn't. > One of the best features of these RFC are their cognitive definition that is > clear,

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

2021-03-28 Thread Deleu
This would lead to inconsistent behavior in the language when short closures auto capture without the auto keyword while multi statements closure doesn't. One of the best features of these RFC are their cognitive definition that is clear, concise, consistent and simple. On Sun, Mar 28, 2021,

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

2021-03-28 Thread Kalle Sommer Nielsen
Hi Rowan Den lør. 27. mar. 2021 kl. 18.05 skrev Rowan Tommins : > Based on those, there seems to be no way to prevent a variable being > captured, even if its value is immediately discarded each time the > closure runs. This may be less than ideal: > > $results = getLargeReportFromDatabase(); >

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

2021-03-27 Thread Mike Schinkel
> On Mar 27, 2021, at 12:05 PM, Rowan Tommins wrote: > > On 27/03/2021 00:05, Nuno Maduro wrote: >> >> I've just added a few more tests with the exact examples you have presented >> in this mail list: >> https://github.com/php/php-src/pull/6246/commits/c3a50d671c5d8fa4b775ec67fe77d0cbd5cc8030

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

2021-03-27 Thread Rowan Tommins
On 27/03/2021 16:52, Larry Garfield wrote: It's a valid point that auto-capture on multi-line function makes the potential for unexpected behavior higher than with a single-line function, simply by virtue of there being more lines of code that could do so. It's not just about number of

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

2021-03-27 Thread Larry Garfield
On Sat, Mar 27, 2021, at 11:05 AM, Rowan Tommins wrote: > On 27/03/2021 00:05, Nuno Maduro wrote: > > > > I've just added a few more tests with the exact examples you have > > presented in this mail list: > >

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

2021-03-27 Thread Rowan Tommins
On 27/03/2021 00:05, Nuno Maduro wrote: I've just added a few more tests with the exact examples you have presented in this mail list: https://github.com/php/php-src/pull/6246/commits/c3a50d671c5d8fa4b775ec67fe77d0cbd5cc8030

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

2021-03-26 Thread Nuno Maduro
Rowan, I've just added a few more tests with the exact examples you have presented in this mail list: https://github.com/php/php-src/pull/6246/commits/c3a50d671c5d8fa4b775ec67fe77d0cbd5cc8030 . On Fri, 26 Mar 2021 at 16:48, Olle Härstedt wrote: > 2021-03-26 17:11 GMT+01:00, Mike Schinkel : >

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

2021-03-26 Thread Olle Härstedt
2021-03-26 17:11 GMT+01:00, Mike Schinkel : >> On Mar 26, 2021, at 8:12 AM, Olle Härstedt >> wrote: >> >> 2021-03-26 3:38 GMT+01:00, Mike Schinkel : >>> >>> On Mar 25, 2021, at 4:09 PM, Olle Härstedt wrote: 2021-03-25 17:49 GMT+01:00, Mike Schinkel : >> On Mar 25, 2021,

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

2021-03-26 Thread Mike Schinkel
> On Mar 26, 2021, at 8:12 AM, Olle Härstedt wrote: > > 2021-03-26 3:38 GMT+01:00, Mike Schinkel : >> >> >>> On Mar 25, 2021, at 4:09 PM, Olle Härstedt >>> wrote: >>> >>> 2021-03-25 17:49 GMT+01:00, Mike Schinkel : > On Mar 25, 2021, at 11:22 AM, Olle Härstedt > wrote: > >

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

2021-03-26 Thread Olle Härstedt
2021-03-26 3:38 GMT+01:00, Mike Schinkel : > > >> On Mar 25, 2021, at 4:09 PM, Olle Härstedt >> wrote: >> >> 2021-03-25 17:49 GMT+01:00, Mike Schinkel : On Mar 25, 2021, at 11:22 AM, Olle Härstedt wrote: 2021-03-25 16:02 GMT+01:00, Mike Schinkel : > > >> On Mar

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 1:57 PM, Rowan Tommins wrote: > > On 25/03/2021 17:14, Mike Schinkel wrote: >> Are you proposing auto-capture but one that is note able to change the >> variable's value in the outer scope? > > > I'm not proposing that, Nuno is. That's what this RFC proposes. Your

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 4:09 PM, Olle Härstedt wrote: > > 2021-03-25 17:49 GMT+01:00, Mike Schinkel : >>> On Mar 25, 2021, at 11:22 AM, Olle Härstedt >>> wrote: >>> >>> 2021-03-25 16:02 GMT+01:00, Mike Schinkel : > On Mar 25, 2021, at 10:41 AM, Rowan Tommins > wrote:

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

2021-03-25 Thread Olle Härstedt
2021-03-25 17:49 GMT+01:00, Mike Schinkel : >> On Mar 25, 2021, at 11:22 AM, Olle Härstedt >> wrote: >> >> 2021-03-25 16:02 GMT+01:00, Mike Schinkel : >>> >>> On Mar 25, 2021, at 10:41 AM, Rowan Tommins wrote: On 25/03/2021 12:31, Nuno Maduro wrote: > The reason why

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 1:19 PM, Chase Peeler wrote: > > On Thu, Mar 25, 2021 at 1:14 PM Mike Schinkel > wrote: > > On Mar 25, 2021, at 12:50 PM, Rowan Tommins > > wrote: > > > > On 25/03/2021 15:02, Mike Schinkel wrote: > >> Can you

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 17:14, Mike Schinkel wrote: Are you proposing auto-capture but one that is note able to change the variable's value in the outer scope? I'm not proposing that, Nuno is. That's what this RFC proposes. Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 17:11, Chase Peeler wrote: I don't think you should keep a function from developers because some people might use it incorrectly. That is not what I said either. I said I am not a fan of the "fn" syntax, because I do not think auto-capture should be seen as the default. If

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

2021-03-25 Thread Chase Peeler
On Thu, Mar 25, 2021 at 1:14 PM Mike Schinkel wrote: > > On Mar 25, 2021, at 12:50 PM, Rowan Tommins > wrote: > > > > On 25/03/2021 15:02, Mike Schinkel wrote: > >> Can you please clarify why "function(...) use(...) {...}" can't be > their solution when someone needs by-reference capture? > > >

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 12:50 PM, Rowan Tommins wrote: > > On 25/03/2021 15:02, Mike Schinkel wrote: >> Can you please clarify why "function(...) use(...) {...}" can't be their >> solution when someone needs by-reference capture? > > > For the same reason - or lack of reason - why it can't be

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

2021-03-25 Thread Chase Peeler
On Thu, Mar 25, 2021 at 12:47 PM Rowan Tommins wrote: > On 25/03/2021 15:05, Deleu wrote: > > > * Because it's shorter, people will decide it's the "better" version, > > > when they don't actually need any variable capture. An explicit syntax > > > like "use(*)" instead makes this a deliberate

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 15:02, Mike Schinkel wrote: Can you please clarify why "function(...) use(...) {...}" can't be their solution when someone needs by-reference capture? For the same reason - or lack of reason - why it can't be the solution when they need by-value capture. In other words,

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 11:22 AM, Olle Härstedt wrote: > > 2021-03-25 16:02 GMT+01:00, Mike Schinkel : >> >> >>> On Mar 25, 2021, at 10:41 AM, Rowan Tommins >>> wrote: >>> >>> On 25/03/2021 12:31, Nuno Maduro wrote: >>> The reason why we believe the vast majority of PHP Developers are

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 15:05, Deleu wrote: > * Because it's shorter, people will decide it's the "better" version, > when they don't actually need any variable capture. An explicit syntax > like "use(*)" instead makes this a deliberate choice. Does this mean you agree that people (PHP users) are very

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

2021-03-25 Thread Chase Peeler
On Thu, Mar 25, 2021 at 11:23 AM Olle Härstedt wrote: > 2021-03-25 16:02 GMT+01:00, Mike Schinkel : > > > > > >> On Mar 25, 2021, at 10:41 AM, Rowan Tommins > >> wrote: > >> > >> On 25/03/2021 12:31, Nuno Maduro wrote: > >> > >>> The reason why we believe the vast majority of PHP Developers are

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

2021-03-25 Thread Olle Härstedt
2021-03-25 16:02 GMT+01:00, Mike Schinkel : > > >> On Mar 25, 2021, at 10:41 AM, Rowan Tommins >> wrote: >> >> On 25/03/2021 12:31, Nuno Maduro wrote: >> >>> The reason why we believe the vast majority of PHP Developers are going >>> to >>> appreciate this RFC is because multi-line short closures

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

2021-03-25 Thread Deleu
> * Because it's shorter, people will decide it's the "better" version, > when they don't actually need any variable capture. An explicit syntax > like "use(*)" instead makes this a deliberate choice. Does this mean you agree that people (PHP users) are very likely to like/enjoy/"think it's the

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 10:41 AM, Rowan Tommins wrote: > > On 25/03/2021 12:31, Nuno Maduro wrote: > >> The reason why we believe the vast majority of PHP Developers are going to >> appreciate this RFC is because multi-line short closures (aka >> Auto-capturing multi-statement closures) *are

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 12:31, Nuno Maduro wrote: The reason why we believe the vast majority of PHP Developers are going to appreciate this RFC is because multi-line short closures (aka Auto-capturing multi-statement closures) *are more simple, shorter to write, and prettier to read *— and the community

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

2021-03-25 Thread Olle Härstedt
I feel like some of these examples would be better covered by command object pattern and data-transaction objects, instead of FP idioms. wrap_in_buffer pretty clearly so. 2021-03-25 10:28 GMT+01:00, Rowan Tommins : > On 25/03/2021 04:12, Mike Schinkel wrote: > >> Actually, there is a way to

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

2021-03-25 Thread Olle Härstedt
> prettier to read Are they though? Because if it implicitly captures anything in scope, there are more lines to read to figure out what's actually captured. 2021-03-25 13:31 GMT+01:00, Nuno Maduro : > Hi, > > Thank you for the feedback on this thread so far. Programmers are > opinionated,

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

2021-03-25 Thread Mike Schinkel
> On Mar 25, 2021, at 5:28 AM, Rowan Tommins wrote: > > On 25/03/2021 04:12, Mike Schinkel wrote: > >> Actually, there is a way to declare a local variable. Use the long function >> syntax instead as there is no proposal to deprecate it. > > That's not quite what I meant. I meant that you

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

2021-03-25 Thread Nuno Maduro
Hi, Thank you for the feedback on this thread so far. Programmers are opinionated, therefore you will find developers that see themselves using this RFC and others who don't. Just like "Fibers", "Type-hints", or any other feature in the language really. The reason why we believe the vast

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

2021-03-25 Thread Rowan Tommins
On 25/03/2021 04:12, Mike Schinkel wrote: Actually, there is a way to declare a local variable. Use the long function syntax instead as there is no proposal to deprecate it. That's not quite what I meant. I meant that you can't say "capture by default, but this variable is definitely

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

2021-03-24 Thread Peter Stalman
On Wed, Mar 24, 2021 at 2:26 PM Mark Randall wrote: > To give my own example, earlier this week I wrote the following: > > $x = function () use ($to, $library, $thread, $author, $title, > $library_name, $top_post) { ... } > > That was just to get those variables inside a callback that could be >

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

2021-03-24 Thread Mike Schinkel
> On Mar 24, 2021, at 6:45 PM, Rowan Tommins wrote: > > On 24/03/2021 21:26, Mark Randall wrote: >> >> Automatic capture ceased to be a dramatic change from PHP the day after >> short closurers were introduced. So they've been a part of PHP for years >> now. > > > I strongly disagree.

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

2021-03-24 Thread Rowan Tommins
On 24/03/2021 21:26, Mark Randall wrote: Automatic capture ceased to be a dramatic change from PHP the day after short closurers were introduced. So they've been a part of PHP for years now. I strongly disagree. Short closures say "turn this expression into a function". You would have to

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

2021-03-24 Thread Chase Peeler
On Wed, Mar 24, 2021 at 5:26 PM Mark Randall wrote: > On 24/03/2021 21:00, Rowan Tommins wrote: > > As Christian says, automatic capture is a dramatic change to the > > language's scoping rules, and IMHO requires a more thorough > > justification on why the current syntax is burdensome. As I've

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

2021-03-24 Thread Mark Randall
On 24/03/2021 21:00, Rowan Tommins wrote: As Christian says, automatic capture is a dramatic change to the language's scoping rules, and IMHO requires a more thorough justification on why the current syntax is burdensome. As I've said previously, my naive impression is that a long list of