Re: Re: [RFC][Discuss] Arrow Functions
| From: | Levi Morrison | Date: | Sat, 04 Feb 2017 21:30:26 +0000 |
| Subject: | Re: Re: [RFC][Discuss] Arrow Functions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98201@lists.php.net to get a copy of this message | ||
> And then there's the extra typing and visual space taken up, which is not
> something to dismiss entirely. Also, as someone else mentioned this syntax
> *seems* like it would support nesting. Compare the following:
>
> $x = function($a) => function($b) => function($c) => $a * $b * $c;
> $y = fn($a) => fn($b) => fn($c) => $a * $b * $c;
> $z = |$a| => |$b| => |$c| => $a * $b * $c;
>
> print $x(1)(2)(3); // prints 6
>
> Which of these is more readable? Id' argue it's not $x.
In a past version the RFC included an example of chaining. The current
version doesn't show an example, but does say it is possible. To be
clear:
$x = fn($a) => fn($b) => fn($c) => $a * $b * $c;
Is supported in the current implementation. It would similarly be
supported in the
|params| => expr notation.