On Fri, Jul 4, 2025, at 5:27 PM, Rob Landers wrote: > On Sat, Jun 28, 2025, at 07:06, Larry Garfield wrote: >> Hi folks. Arnaud and I would like to present take-2 at Partial Function >> Application. >> >> https://wiki.php.net/rfc/partial_function_application_v2 >> >> It is largely similar to the previous PFA proposal from 2021, though there >> are a number of changes. Most notably: >> >> * The implementation is simpler, because FCC already did part of the work. >> This RFC can build on it. >> * Constructors are not supported. >> * But optional arguments and named placeholders are supported. >> * It includes pipe-based optimizations. >> >> Note: We realize that this is a non-trivial RFC coming late in the cycle. >> We are proposing it now because, well, it's ready now. If the discussion >> goes smoothly, we're OK calling a vote on it for 8.5, especially as it would >> complement pipes so well. If the discussion runs longer, we're also OK with >> targeting 8.6 instead. We'll see how that goes. >> >> <floor opens for discussion, Larry falls through the trap door> >> >> -- >> Larry Garfield >> la...@garfieldtech.com >> > > Hi Larry, > > I hope your trip through the trap door is largely uneventful with a > smooth integration into 8.5. > > My only question: why does this implementation care if you specify too > many arguments when PHP doesn’t care if you call a function with too > many arguments? > > I think it’s a good thing that it cares, and I think PHP itself should > care, but should this RFC change that expectation? > > — Rob
Largely because it conflicts with the intent of the closure author, and may have unexpected interaction with optional args otherwise. Eg: function f($a, $b = 0) {} $f = f(?); $f(1, 2); Is 2 bound to $b ? If yes this goes against the intent of the PFA creator. But if not this is weird. Therefore it’s better if that’s not allowed, as that's the least-weird outcome. If the closure author wants to allow trailing arguments, they can use the ... placeholder, which would allow for that. So: function f($a, $b = 0) {} $f = f(?, ...); $f(1, 2); It's self-evident that trailing args are allowed, and that it's the author's intent, so in this case all is well and there's no (unexpected) weirdness. --Larry Garfield