Re: [RFC] Spread Operator in Array Expression v0.2
| From: | Claude Pache | Date: | Sat, 13 Apr 2019 14:07:24 +0000 |
| Subject: | Re: [RFC] Spread Operator in Array Expression v0.2 | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105267@lists.php.net to get a copy of this message | ||
> Le 13 avr. 2019 à 11:09, Stijn Peeters <ik@stijnpeeters.nl> a écrit :
>
> Is anyone aware of other arguments for not allowing normal arguments after
> unpackable arguments in function calls?
I've grabbed into the archives of internals. Apart from technical issues:
The main argument against that affordance was static analysis; i.e., in
f(...$a, $b),
it cannot be known until runtime at what position is the argument $b. An interesting
particular case is that an unfortunate programmer might write strpos(...$arr, $offset),
not realising that it is not equivalent to strpos($arr[0], $arr[1], $offset).
Another argument was readability, i.e. difficulty to sort out positions with and without spread when
they are intermixed.
For the case of spread operator in arrays, the static analysis argument probably does not apply.
—Claude