Den 2015-10-01 kl. 19:12, skrev Bishop Bettini:
On Thu, Oct 1, 2015 at 12:28 PM, Anthony Ferrara <ircmax...@gmail.com>
wrote:

Nikita and all,

I don't think there was a dozen of different ideas, I could only find
those
about `lambda(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 syntax
nor
`fn(arg-list; use-list) expression` look obvious and easily readable to
me.

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.
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;
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örn


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to