Le Wed, 16 Jun 2021 11:16:28 -0500, "Larry Garfield" <la...@garfieldtech.com> a écrit :
> Hi folks. The vote for the Partial Function Application RFC is now open, and > will run until 30 June. > > https://wiki.php.net/rfc/partial_function_application I do not understand how this ... placeholder works, it feels inconsistent. From the examples: > $c = stuff(...); > $c = fn(int $i, string $s, float $f, Point $p, int $m = 0) > => stuff($i, $s, $f, $p, $m); > $c = stuff(1, 'hi', 3.4, $point, 5, ...); > $c = fn(...$args) => stuff(1, 'hi', 3.4, $point, 5, ...$args); Why is there an additional variadic parameter in this one? If I remove the 5: > $c = stuff(1, 'hi', 3.4, $point, ...); I get this right?: > $c = fn(int $m = 0) => stuff(1, 'hi', 3.4, $point, $m); Why the ... does not produce 0 parameters when there are none left? Also, in the second set of examples: > function things(int $i, float $f, Point ...$points) { ... } > // Ex 13 > $c = things(...); > $c = fn(int $i, float $f, ...$args) => things(...[$i, $f, ...$args]); > // Ex 14 > $c = things(1, 3.14, ...); > $c = fn(...$args) => things(...[1, 3.14, ...$args]); What happens to the typing of the variadic parameter here? Why is it removed? It would feel natural that the ... means "copy the rest of the parameters from signature". Here it seems it sometimes mean that, and sometimes mean "accept an additional variadic parameter and pass it along". Côme -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php