Re: [RFC] Arrow functions / short closures
| From: | Rowan Collins | Date: | Thu, 14 Mar 2019 06:16:59 +0000 |
| Subject: | Re: [RFC] Arrow functions / short closures | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-104708@lists.php.net to get a copy of this message | ||
On 14 March 2019 04:01:54 GMT+00:00, David Rodrigues <david.proweb@gmail.com> wrote:
>1. Your example with "($x) => $x" consider the use of "$x => $x", but
>not
>specifically "($x) => $x". I mean: maybe it can accept "($x) => $x"
>but
>not
>"$x => $x" because of the array conflict (as mentioned), and with that
>we
>avoid to create a new keyword "fn". So parentheses is required.
I don't think this helps, because you can put brackets around any expression, for precedence,
and any expression can appear on the left of an array literal:
$foo = [ ($bar + 1) * 2 => $baz ];
So the following, while redundant, is currently valid:
$foo = [ ($bar) => $baz ];
Regards,
--
Rowan Collins
[IMSoP]