Re: [RFC]Discuss] Syntax for Arrow Functions

From: Date: Mon, 05 Jun 2017 19:03:45 +0000
Subject: Re: [RFC]Discuss] Syntax for Arrow Functions
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-99377@lists.php.net to get a copy of this message
On Jun 5, 2017 12:53 PM, "Fleshgrinder" <php@fleshgrinder.com> wrote: 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'); However, ($obj) -> $var is valid variable property syntax. It also avoid any association with <?= which prints, not returns, and any other assignment related thing. -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#99377) next »