On Jun 5, 2017 12:53 PM, "Fleshgrinder" <[email protected]> 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