Re: [RFC]Discuss] Syntax for Arrow Functions
| From: | Fleshgrinder | Date: | Mon, 05 Jun 2017 18:52:05 +0000 |
| Subject: | Re: [RFC]Discuss] Syntax for Arrow Functions | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-99374@lists.php.net to get a copy of this message | ||
On 6/5/2017 8:36 PM, Rasmus Schultz wrote:
> Ugh, you're right, that's totally unreadable... the => is far too ambiguous
> with array syntax, I agree.
>
> How about just a thin arrow?
>
> (params) -> expr
>
> If the parens around params were required, it's not ambiguous with the
> trailing -- operator, is it?
>
> $foo->bar(($baz) -> $baz + 1);
>
> Consistent use of parens around the params might make closures a bit easier
> to spot in the wild?
>
This would actually work with everything, me likes.
() -> 42
($a, $b) -> $a + $b
($a) (&$b) -> $b += $a
public static Foo() -> new static('Foo');
It also avoid any association with <?= which prints, not returns, and
any other assignment related thing.
--
Richard "Fleshgrinder" Fussenegger
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc