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

From: Date: Fri, 12 Apr 2019 15:26:45 +0000
Subject: Re: Re: [RFC] Arrow functions / short closures
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.internals 
Request: Send a blank email to internals+get-105263@lists.php.net to get a copy of this message
> 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]: https://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.

« previous php.internals (#105263) next »