On 26/09/2015 19:37, Levi Morrison wrote:
Thank you for the feedback. I feel like the rest of what you proposed
was a bit too far outside of the box. For what it is worth no token
after the paren is necessary – you could do `fn($x) $x * 2` (or
`function($x) $x * 2`). I think this is a case where more syntax
helps.
Here they are on separate lines so you can see things more clearly:
$output = array_map(function($x) $x * 2, $input);
$output = array_map(function($x) => $x * 2, $input);
I think the arrow helps.
I meant more that the lack of parens around the whole expression looks
odd - the => is no longer just an operator linking two expressions, it's
an arbitrary piece of syntax inserted just because it feels like
something should go there (and I agree it does look more readable than
nothing at all).
How about a variant on existing curly braces:
fn($x) { $x * 2 }
lambda($x) { $x * 2 }
Or the arrow inside the parens:
fn($x => $x * 2)
function($x => $x * 2)
My point is that there are plenty of other variants, if we're no longer
mimicking the "(params) => expression" syntax of other languages.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php