Hi Larry,
strictly from a userland perspective, I believe reordering is necessary.
Kind regards,
Marc
-------- Original message --------
From: Larry Garfield larry@garfieldtech.com
Date: 30/10/2025 19:46 (GMT+01:00)
To: php internals internals@lists.php.net
Subject: Re: [PHP-DEV] [RFC] Partial Function Application v2
Hi folks. PFA is back. :-)
Since our last episode, Arnaud has greatly revised the implementation.
Rather than emulating a closure and all the associated behavior, the
new approach compiles PFAs into normal closures at runtime, leveraging
opcache. The resulting closure is then "just a closure," and will
behave like any other. That means, for instance, its behavior in
debugging, reflection, etc. is all self-evident.There were a few small behavior changes as a result, but not
dramatically. Mainly it impacted variadic cases, where parameter names
are now auto-generated when appropriate rather than simply being
unnamed.We have also changed the order of placeholders from "positional,
variadic, named" to "positional, named, variadic." Meaning the...
"and the rest" placeholder is always at the end of the call.One outstanding question is whether to allow reordering of parameters
in the PFA closure by using named arguments. With this implementation,
Arnaud says it's possible to do if we decide to. I am still concerned
that it would create too much complexity and confusion in practice.
But we're willing to go with a broad consensus if it emerges.https://che01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.php.net%2Frfc%2Fpartial_function_application_v2&data=05%7C02%7C%7C39bef3870b8447d6f3f608de17e4adde%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638974468098471876%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=z0XjY%2Fk6w8B7N%2B%2Bp%2BG6eopuA0en35kkow2%2Fz20m%2FJuQ%3D&reserved=0https://wiki.php.net/rfc/partial_function_application_v2
--Larry Garfield
Another set of updates.
- Some improvements to the error handling and error messages.
- Clarified that PFA is compatible with constant expressions.
- Clarified when the resulting closure is static or not.
The main change is we revisited how extra arguments are handled. Long story short, they now forward only if the PFA has a ..., and how they forward depends on if the underlying function is variadic or not.
The RFC now includes more precise examples of how the desugaring works, including the variadic/func_get_args cases, which should make it all a lot clearer.
The one outstanding question is whether we allow reordering using named arguments or preserve the underlying order. Arnaud says either one is doable. So far, only 2 people have commented on it (favoring reordering). We still want feedback from more people to see if there really is a consensus one way or another. (2 people is too small a sample size to draw any conclusions.)
Also, if anyone not named Tim would like to weigh in, now is the time. :-)
--Larry Garfield