On Fri, Apr 12, 2019 at 4:27 PM Fabien S <fabacr...@gmail.com> wrote:
>
>
> > On 12 Apr 2019, at 16:46, Theodore Brown <theodor...@outlook.com> wrote:
> >
> > On Thursday, April 11, 2019 at 10:22 AM Fabien S <fabacr...@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.

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
>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to