On 05/06/2017 20:09, Fleshgrinder wrote:
How about ~> which I at least cannot think of any place it is used at
all. ~ in binary negation and the only place we use it (I checked the
language parser this time to make sure).

We've come full circle: that was actually the syntax proposed in Bob Weinand's (rejected) RFC two years ago: https://wiki.php.net/rfc/short_closures

There are several reasons the RFC was rejected, but IIRC the syntax was one of them. I think ~ isn't available on all keyboard layouts, and some people just didn't like the look of it.


Looking at earlier drafts of the current RFC reminds me of a couple of points which have been slimmed down a bit in the current edit:

1) As well as inside arrays, => is used to represent key-value pairs in yield statements:

// Does this mean:
//   1. Yield a key with the result of `($x)` and a value with `$x * 2`
//   2. Yield an anonymous function
yield ($x) => $x * 2;

2) The prefix (fn, function, lambda, etc) allows us to insert type hints without adding awkward complexities to the parser:

> In the definition (Type &$x) => expr the part (Type &$var) can parse as “take constant Type and variable $var and do a bitwise and & operation.” > After that the => will be an unexpected token. Even though the rule would be invalid the parser doesn't know that far ahead there will be an error and it doesn't know which rule to pick.

Regards,

--
Rowan Collins
[IMSoP]


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

Reply via email to