Re: Arrow function expressions in PHP
| From: | Björn Larsson | Date: | Thu, 01 Oct 2015 19:55:55 +0000 |
| Subject: | Re: Arrow function expressions in PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88621@lists.php.net to get a copy of this message | ||
Den 2015-10-01 kl. 19:12, skrev Bishop Bettini:
On Thu, Oct 1, 2015 at 12:28 PM, Anthony Ferrara <ircmaxell@gmail.com> wrote:with several parameters? And if one could solve the parser problem it could be with typehint & a default value either: (int $a = 10, int $b @ $c, $d) => $a + $b + $c + $d; or (int $a = 10, int $b @ $c, $d) ==> $a + $b + $c + $d; or (int $a = 10, int $b @ $c, $d) ~> $a + $b + $c + $d; Regards //BjörnNikita and all,True. But a developer can mitigate with judicious white-space: fn($a, $b ; $c) => $a+$b+$c Or we can figure out some other such symbol. Worse casing no white space, brain storming: fn($a,$b:$c) => $a+$b+$c // not much better fn($a,$b!$c) => $a+$b+$c // better, but looks like not fn($a,$b&$c) => $a+$b+$c // lost in the noise, looks like bitwise fn($a,$b%$c) => $a+$b+$c // perl jibberish, looks modulo fn($a,$b--$c) => $a+$b+$c // multi-char, looks like decrement fn($a,$b::$c) => $a+$b+$c // maybe, kinda confusing // my favorite fn($a, $b @ $c) => $a + $b + $c; Would it be: fn($a, $b @ $c, $d) => $a + $b + $c + $d;I don't think there was a dozen of different ideas, I could only findthoseaboutnorlambda(arg-list; use-list; expression)and variations of it with different keywords and different return-type syntax. I do understand that this is quite subjective, but neither this syntaxme. The problem is that semicolons are non-obvious, especially in a context where commas are used (and traditionally used). Example, tell the difference quickly between fn($a, $b; $c) => $a + $b + $c; and fn($a; $b, $c) => $a + $b + $c. At a glance, they are identical. You have to actually look at each item to realize that there's a difference. At least with use() there's a syntactical separator there to draw your eye to the contextually relevant information.fn(arg-list; use-list) expressionlook obvious and easily readable to