Re: [PHP-DEV] [RFC] Short-function syntax

2020-11-05 Thread Larry Garfield
On Wed, Nov 4, 2020, at 4:05 PM, Nuno Maduro wrote: > Hey Larry, > > In my vision, this proposal is a good addition to PHP exactly as stated in > this pull request (https://github.com/php/php-src/pull/6221): where only > the "=> expr;" is introduced, and not the "fn". > > For visual consistency i

Re: [PHP-DEV] [RFC] Short-function syntax

2020-11-04 Thread Nuno Maduro
Hey Larry, In my vision, this proposal is a good addition to PHP exactly as stated in this pull request (https://github.com/php/php-src/pull/6221): where only the "=> expr;" is introduced, and not the "fn". For visual consistency in the future of PHP functions/methods, I think it's important to d

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-27 Thread Larry Garfield
On Tue, Oct 27, 2020, at 1:35 AM, Mike Schinkel wrote: > > > > On Oct 26, 2020, at 10:23 AM, Michał Marcin Brzuchalski > > wrote: > > > > Hi Larry, > > > > I'm wondering why we hadn't thought yet about reducing the need for $this > > in this syntax. > > Since arrow functions have an ability t

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-26 Thread Mike Schinkel
> On Oct 26, 2020, at 10:23 AM, Michał Marcin Brzuchalski > wrote: > > Hi Larry, > > I'm wondering why we hadn't thought yet about reducing the need for $this > in this syntax. > Since arrow functions have an ability to capture variables defined in > parent scope why not > think of the same f

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-26 Thread Michał Marcin Brzuchalski
Hi David, pon., 26 paź 2020 o 15:29 David Rodrigues napisał(a): > > The use of > instead of => could if possible indicate the method being > void > > and reduce even more: > > I think that for void, it could just identify it and not return nothing > automatically. > > function a(): int => b(); /

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-26 Thread David Rodrigues
> The use of > instead of => could if possible indicate the method being void > and reduce even more: I think that for void, it could just identify it and not return nothing automatically. function a(): int => b(); // equivalents to function a(): int { return b(); } function x(): void => y(); //

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-26 Thread Michał Marcin Brzuchalski
Hi Larry, I'm wondering why we hadn't thought yet about reducing the need for $this in this syntax. Since arrow functions have an ability to capture variables defined in parent scope why not think of the same for class properties which will automatically reduce short methods verbosity. class X {

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-26 Thread Nikita Popov
On Tue, Oct 20, 2020 at 8:20 PM Larry Garfield wrote: > A while back, Nikita mentioned that it should now be easy to offer an > abbreviated syntax for functions that are just a single expression. I > decided to take a crack at it and it turns out he was right. I thus offer > this RFC: > > https

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread Mike Schinkel
> On Oct 21, 2020, at 8:50 AM, Larry Garfield wrote: > > On Tue, Oct 20, 2020, at 11:08 PM, Mike Schinkel wrote: >>> On Oct 20, 2020, at 2:19 PM, Larry Garfield wrote: >>> >>> A while back, Nikita mentioned that it should now be easy to offer an >>> abbreviated syntax for functions that are ju

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread Larry Garfield
On Wed, Oct 21, 2020, at 5:17 PM, Rowan Tommins wrote: > It occurred to me recently that maybe we could make "function" and "fn" > synonyms everywhere, i.e. make both "$double = function($x) => $x *2;" > and "$double = fn($x) use ($x) { return $x *2; };" valid. I'm not sure > if that's desirabl

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread Rowan Tommins
On 21/10/2020 21:53, Larry Garfield wrote: A while back, Nikita mentioned that it should now be easy to offer an abbreviated syntax for functions that are just a single expression. I decided to take a crack at it and it turns out he was right. I thus offer this RFC: https://wiki.php.net/rfc/sh

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread tyson andre
Hi Larry Garfield, > > A while back, Nikita mentioned that it should now be easy to offer an > > abbreviated syntax for functions that are just a single expression.  I > > decided to take a crack at it and it turns out he was right.  I thus > > offer this RFC: > > > > https://wiki.php.net/rfc/

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread Larry Garfield
On Tue, Oct 20, 2020, at 1:19 PM, Larry Garfield wrote: > A while back, Nikita mentioned that it should now be easy to offer an > abbreviated syntax for functions that are just a single expression. I > decided to take a crack at it and it turns out he was right. I thus > offer this RFC: > > h

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-21 Thread Larry Garfield
On Tue, Oct 20, 2020, at 11:08 PM, Mike Schinkel wrote: > > On Oct 20, 2020, at 2:19 PM, Larry Garfield wrote: > > > > A while back, Nikita mentioned that it should now be easy to offer an > > abbreviated syntax for functions that are just a single expression. I > > decided to take a crack at

Re: [PHP-DEV] [RFC] Short-function syntax

2020-10-20 Thread Mike Schinkel
> On Oct 20, 2020, at 2:19 PM, Larry Garfield wrote: > > A while back, Nikita mentioned that it should now be easy to offer an > abbreviated syntax for functions that are just a single expression. I > decided to take a crack at it and it turns out he was right. I thus offer > this RFC: > >