Re: Re: [RFC] Arrow functions / short closures

From: Date: Fri, 12 Apr 2019 15:40:34 +0000
Subject: Re: Re: [RFC] Arrow functions / short closures
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  Groups: php.internals 
Request: Send a blank email to internals+get-105264@lists.php.net to get a copy of this message
On Fri, Apr 12, 2019 at 4:27 PM Fabien S <fabacrans@gmail.com> wrote: > > > > On 12 Apr 2019, at 16:46, Theodore Brown <theodorejb@outlook.com> wrote: > > > > On Thursday, April 11, 2019 at 10:22 AM Fabien S <fabacrans@gmail.com> wrote: > > > >> I really like the Haskell \($x) syntax, could someone > >> confirm if > >> it would possible to drop the parenthesis (like \$x) > >> if we have > >> one argument ? > > > > The RFC says this syntax is ambiguous without the parentheses, since > > the \ may also be part of a fully qualified type name. [1] > > > > I'm not sure whether it would work if the single parameter isn't typed. > > > > I like the Haskell syntax as well, but I'd also be okay with the > > fn > > keyword if that's what others prefer. > > > > [1]: +‚ > > ¼ì8xí¦Lâ4Nhttps://wiki.php.net/rfc/arrow_functions_v2#miscellaneous > > > Thanks for the clarification, I should have been more specific but I saw you used > \$x in your previous message and I was wondering if this syntax is > unambiguous. > > Basically: > > ```php > \$x => $x + 1; // One (not typed) argument, no parenthesis needed > \(int $x) => $x + 1; // Typed, parenthesis needed > \($x, $y) => $x + $y; // Multiple arguments, parenthesis needed > ``` > > I don't think it's really important but it would be pretty handy syntax in my humble > opinion. Agreed. Arrow functions work the same way in TypeScript I think (parens are required for typed parameters). > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.internals (#105264) next »