> On May 14, 2021, at 7:00 PM, Larry Garfield <la...@garfieldtech.com> wrote:
> 
> Is that actually going to come up?  Given that PHP functions (at least 
> user-space ones) accept extra trailing arguments and just let them fall off, 
> I would *expect* a closure that way to do the same.  Named arguments continue 
> that, I believe, by just ignoring any variadic arguments that do not match a 
> parameter in the function.  It seems odd to go back on that behavior now.

I don't consider forwarding extra arguments an issue. I briefly was thinking it 
might be nice to be explicit about the number of arguments a partial would 
accept, but you convinced me otherwise in R11, so I think we're on the same 
page here.

> 
> I can't speak for the others, but I could tolerate making "more than one 
> extra ? beyond the end of the parameter list is an error", potentially, as at 
> that point they're redundant.  But if a function has, say, 4 params, then 
> fourParams(1, 3, ?) is a convenient way to say "and placeholder everything 
> else".  Especially in dynamic cases like Nicolas pointed out, you may not 
> necessarily know how many arguments there are.

With what I proposed in my last email, `fourParams(1, 3, ?)` is acceptable, 
there's nothing superfluous there. At least one ? is needed to declare a 
partial. Similarly, a partial for a no parameter function: `$partial = 
functionTakingNoParams(?)`. Or even a partial with args bound to all four 
params: `fourParams(1, 2, 3, 4, ?)`.

What would error is `fourParams(1, 3, ?, ?)`, as the second ? is meaningless.

I think you've convinced me that one-for-one matching on ? is burdensome, but 
the above is a happy medium perhaps?

Cheers,
Aaron Piotrowski

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to