Re: Re: [RFC][Discuss] Arrow Functions
| From: | Yasuo Ohgaki | Date: | Sat, 04 Feb 2017 07:14:57 +0000 |
| Subject: | Re: Re: [RFC][Discuss] Arrow Functions | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98171@lists.php.net to get a copy of this message | ||
Hi Levi,
On Sat, Feb 4, 2017 at 2:53 AM, Levi Morrison <levim@php.net> wrote:
> One more thing: I'd like to re-emphasize that the syntax that
> JavaScript uses and the one that HHVM/Hack uses are ambiguous in the
> current class of our grammar. The following will not work unless we
> move to a more powerful grammar and parser class:
>
> (params) => expr
> (params) ==> expr
>
> This is why an un-ambiguous prefix is necessary: the prefix breaks the
> ambiguities. The syntax I have suggested in the RFC and the one I
> suggested just now are not ambiguous because distinct prefixes:
>
Thanks for explanation.
> an un-ambiguous prefix is necessary
This is what I guessed.
This should be emphasized and everyone should understand.
Otherwise, discussion goes nowhere.
> fn(params) => expr
> |params| => expr
>
> I look forward to more discussion!
>
It's unfortunate we cannot have HHVM/Hack syntax now
https://docs.hhvm.com/hack/lambdas/introduction
but both
fn(params) => expr
|params| => expr
would be good enough for now. I don't see much problem with
|(int | float) params| => expr
It's better to be compatible with other implementations if it is possible.
PHP may have HHVM/Hack syntax support in the future.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net