Hi folks!

Today, I want to announce my second RFC to php 8.7
https://wiki.php.net/rfc/array_shorthand

This RFC brings a IMO useful syntactic sugar to array's
construction and destruction. I hope you'all find this
interesting! To be short:

```
$point = [:$x, :$y, :$z]; // ['x' -> $x, 'y' -> $y, 'z' -> $z]
[:$x, :$y, :$z] = $point; // reverse.
```

We also support the foreach syntax ofc, see examples
in the RFC.

Same feature has been implemented in perl. And 13
years ago the named argument RFC have already
list this as part of the future scope [1]

Some may ask why don't you propose this for all
functions but just for the `[]` syntax in arrays? Well,
sadly I don't have enough time and energy to put
in php now (I am unfunded) so I will leave it for others
if they want in the future. 

Again I hope you'all find this useful and interesting :)

Thank you,
Weilin Du

[1]: 
https://wiki.php.net/rfc/named_params#shorthand_syntax_for_matching_parameter_and_variable_name

Reply via email to