Argument unpacking - Multiple unpacks and trailing arguments
| From: | Nikita Popov | Date: | Mon, 23 Sep 2013 19:33:07 +0000 |
| Subject: | Argument unpacking - Multiple unpacks and trailing arguments | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-69292@lists.php.net to get a copy of this message | ||
Hi internals!
I'd like to finish up the argument unpacking proposal (
https://wiki.php.net/rfc/argument_unpacking).
The main open question (or at least the focus of the discussion) seems to
be whether to allow multiple unpacks and trailing arguments.
An example of multiple unpacks is the bind() function:
function bind(callable $function, ...$boundArgs) {
return function(...$args) use($function, $boundArgs) {
return $function(...$boundArgs, ...$args);
}
}
This example is detailed a bit more in the RFC:
https://wiki.php.net/rfc/argument_unpacking#partial_applicationmultiple_unpacks
An example of trailing arguments are array intersections and diffs using a
custom compare function:
array_uintersect(...$arrays, $compare);
array_udiff(...$arrays, $compare);
// also array_intersect_uassoc and all those other variations on the
topic
Some people expressed concern about allow both usages (multiple unpacks /
trailing args). I have a bit of a hard time understanding this (as there
clearly are practical applications for both), so I'd appreciate some more
opinions on the topic.
Thanks,
Nikita