On Tue, May 18, 2021 at 2:45 PM Larry Garfield <la...@garfieldtech.com> wrote:
> User-space functions have always accepted more arguments than they're > defined with. They just get dropped off the end silently, unless you use > func_get_args() or variadics. While I know not everyone likes that > "feature", it means that extra trailing ? "arguments" don't feel weird to > me. They just get dropped off the end and we move on with life. At least > that's how I conceptualize them. > This is my question about the partials feature, though; does the implementation have potential to reasonably be confusing? if it's essentially a convenient way of creating a closure, why would extra arguments passed in the closure call be passed to the wrapped function, rather than discarded? function foo(int $a, int $b, int ...$p) { ... } $partial = foo(?, 10); $partial(5, 15, 25); Intuitively, because the existing convention is extra unused parameters in user defined functions are silently ignored, I think I would expect the above to be equivalent to something like: $partial = fn(int $a) => foo($a, 10); $partial(5, 15, 25); // 15 and 25 are lopped off to no effect and not $partial = fn(int $a, int ...$params) => foo($a, 10, ....$params); But correct me if I'm wrong, isn't the latter what the RFC effectively proposes? > > --Larry Garfield > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >