On 15 May 2021 00:09:41 BST, Paul Crovella <paul.crove...@gmail.com> wrote: >I think this highlights where the misunderstanding of this feature is.
I think the fact that there is so much confusion highlights why it is worth considering different designs. >Partial application is about binding arguments. ? isn't an argument, >it's an argument placeholder. It does two things: signals to create a >closure wrapping the function rather than calling it immediately, and >holds a position in the argument list so that an argument further to >the right can be fixed (bound) at that time. This is not a correct description of the current syntax. Currently, "?" represents a *required* argument in the argument list, but *only* if there is a fixed value to its right. If it appears at the end of the argument list, or with only other ? tokens to its right, it *only* signals that a partial should be created, and doesn't create a required argument, even though it looks the same. foo(?, 42) creates a closure with one required argument; foo(42, ?) creates a closure with no required arguments >Requiring additional trailing argument placeholders or adding an >additional token `...?` unnecessarily complicates things, burdens the >user, and only serves to further promote misunderstanding. On the contrary, saying that "?" always means exactly one argument massively simplifies the description of the feature. Why persist with a version of the syntax that is so easy to misunderstand when we have a really simple fix available? I acknowledge the need for a syntax to say "accept zero or more further arguments", but this doesn't need to overload the syntax for "create a required argument here". If the suggestion of ...? is too long, we could look at other options like ... or ?? The syntax for "just make a closure and pass all arguments through" would then be "foo(...)" or "foo(??)". There is a *separate* question of whether arguments that weren't *required* are passed along anyway. I'm less sure there's a right answer there, and would be happy with a version where foo(?, 42) and foo(?, 42, ...) were equivalent - that is, the trailing "all other arguments" token would only be needed if there wasn't already a placeholder. Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php