Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-11-03 Thread Christoph M. Becker
On 03.11.2020 at 21:52, Nuno Maduro wrote: > Hey internals, > > Thank you for the feedback on this thread so far. > > I think a detailed RFC will help to clarify the proposal and reasoning > behind the chosen syntax. And after that, we can keep discussing the > proposal. > > So I can move forward,

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-11-03 Thread Nuno Maduro
Hey internals, Thank you for the feedback on this thread so far. I think a detailed RFC will help to clarify the proposal and reasoning behind the chosen syntax. And after that, we can keep discussing the proposal. So I can move forward, do you mind giving me the necessary karma to create RFCs?

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-30 Thread Benjamin Morel
On Fri, 30 Oct 2020 at 19:07, Rowan Tommins wrote: > Just to be clear, the major gain here is not replacing the 10 characters > "function()" with the 7 characters "fn() =>", it is eliminating the list > of captured variables. So you would get equally clean code with a > "capture all" syntax, such

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-30 Thread Rowan Tommins
On 29/10/2020 22:49, Benjamin Morel wrote: On Tue, 6 Oct 2020 at 14:09, G. P. B. wrote: Actually there is a precedent in PHP where braces don't create a new scope: $a = 1; { $a++; } echo $a; // 2 This is true. Indeed, in general, scope in PHP is not to the ne

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-29 Thread Sara Golemon
On Mon, Oct 5, 2020 at 5:09 AM Lynn wrote: > How should php deal with the scenario where you want to `use` everything > and have one variable by reference? > > ``` > function () use (*, &$butNotThisOne) {}; > ``` I would take a page out of C++'s book here. In C++ a closure is (some of these bits

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-29 Thread Benjamin Morel
On Tue, 6 Oct 2020 at 14:09, G. P. B. wrote: > And once *again* short-closure don't *just* have the auto-import of the > outer scope going for it. > The other main features of the short closure are not applicable to a block > syntax. > - the fact that there is an implicit return > - it is a sin

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-07 Thread Rowan Tommins
Hi Brent, On 06/10/2020 09:53, Brent Roose wrote: We can have the discussion again on whether we like short closures or not, but it turned out most of internals_and_ userland devs do — based on the vote count in the sigle line RFC and the reaction on Nuno's PR, as well as my experience from

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-06 Thread G. P. B.
On Tue, 6 Oct 2020 at 12:20, Brent Roose wrote: > The point of short closures, regardless of single line or multi line, is > addressed (and agreed upon by the RFC votes) in the first pararaph of the > RFC [1]. I'm not sure if I can add anything useful rather than saying "it's > nice to be able to

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-06 Thread G. P. B.
On Tue, 6 Oct 2020 at 11:28, G. P. B. wrote: > First, can you please bottom-post and not top-post. > > On Tue, 6 Oct 2020 at 09:53, Brent Roose wrote: > >> Hi internals >> >> The reason multi-line short closures are so valued by userland devs is >> because they are shorter to write and prettier

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-06 Thread G. P. B.
First, can you please bottom-post and not top-post. On Tue, 6 Oct 2020 at 09:53, Brent Roose wrote: > Hi internals > > The reason multi-line short closures are so valued by userland devs is > because they are shorter to write and prettier to read. While some of us > might not agree on the defini

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-06 Thread Brent Roose
Hi internals The reason multi-line short closures are so valued by userland devs is because they are shorter to write and prettier to read. While some of us might not agree on the definition of "prettier to read", it was one of the key arguments for adding short closures in the first place: >

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Markus Fischer
On 05.10.20 12:24, Andreas Leathley wrote: On 05.10.20 12:08, Lynn wrote: How should php deal with the scenario where you want to `use` everything and have one variable by reference? ``` function () use (*, &$butNotThisOne) {}; ``` The easiest would be to only allow "use (*)" with no referenc

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Andreas Leathley
On 05.10.20 12:15, Deleu wrote: To me that seems like a great argument in favour of the proposal. If you'll want all variables to be imported (which in this case makes completely sense), then `fn() {}` or `fn() => {}` is much less verbose and inline with the mentality to reach for short closures.

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Andreas Leathley
On 05.10.20 12:08, Lynn wrote: How should php deal with the scenario where you want to `use` everything and have one variable by reference? ``` function () use (*, &$butNotThisOne) {}; ``` The easiest would be to only allow "use (*)" with no references or additional syntax. "use (*)" would onl

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Deleu
To me that seems like a great argument in favour of the proposal. If you'll want all variables to be imported (which in this case makes completely sense), then `fn() {}` or `fn() => {}` is much less verbose and inline with the mentality to reach for short closures. We reach for short closures to av

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Lynn
On Mon, Oct 5, 2020 at 12:00 PM Michael Voříšek - ČVUT FEL < voris...@fel.cvut.cz> wrote: > Yes, "use (*)" is perfect! > > With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem, > > Michael Voříšek > > On 5 Oct 2020 11:57, Andreas Leathley wrote: > > > On 04.10.20 22:08, Rowan Tommi

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Michael Voříšek - ČVUT FEL
Yes, "use (*)" is perfect! With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem, Michael Voříšek On 5 Oct 2020 11:57, Andreas Leathley wrote: On 04.10.20 22:08, Rowan Tommins wrote: If we added an opt-in syntax for "capture everything", we might instead write this: $f = fun

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-05 Thread Andreas Leathley
On 04.10.20 22:08, Rowan Tommins wrote: If we added an opt-in syntax for "capture everything", we might instead write this: $f = function() use (*) { $x = $y = $z = null; } Without re-initialising all local variables, we would no longer be able to know if they were actually local without l

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-04 Thread Mike Schinkel
> On Oct 4, 2020, at 4:08 PM, Rowan Tommins wrote: > > Hi Nuno, > > On 03/10/2020 22:09, Nuno Maduro wrote: >> A few days ago I opened a pull request that adds support for multi-line >> arrow functions in PHP: https://github.com/php/php-src/pull/6246. > > > Welcome to the list. Firstly, it's p

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-04 Thread Rowan Tommins
Hi Nuno, On 03/10/2020 22:09, Nuno Maduro wrote: A few days ago I opened a pull request that adds support for multi-line arrow functions in PHP: https://github.com/php/php-src/pull/6246. Welcome to the list. Firstly, it's probably worth having a look in the mailing list archives for prior di

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-03 Thread Deleu
Hi Nuno, thank you very much for kicking this off! The current state of short closure is very limited and I believe it was a stepping stone to get to this one. This time there's no drawback of making fn a reserved keyword since it already is. This change will lead to better consistency and it will

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-03 Thread Benjamin Morel
> > If you want to make an RFC about it, it really needs a compelling "pros" > section, because there aren't any, so far :-\ I don't agree. There is one pro, and not a small one IMO if you use closures a lot: skip use(). Since arrow functions have been introduced, I've several times naturally tr

Re: [PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-03 Thread Marco Pivetta
Hey Nuno, On Sat, Oct 3, 2020 at 11:09 PM Nuno Maduro wrote: > Hey internals, > > > A few days ago I opened a pull request that adds support for multi-line > arrow functions in PHP: https://github.com/php/php-src/pull/6246. > > > As you may already know, PHP 7.4 ha

[PHP-DEV] RFC: Support for multi-line arrow functions

2020-10-03 Thread Nuno Maduro
Hey internals, A few days ago I opened a pull request that adds support for multi-line arrow functions in PHP: https://github.com/php/php-src/pull/6246. As you may already know, PHP 7.4 has introduced one-liner arrow functions (aka short closures). Now, this pull request adds the possibility of