Hi
Am 2025-10-09 20:54, schrieb Larry Garfield:
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.
I still believe that this is *less* confusing, as I outlined before.
https://wiki.php.net/rfc/partial_function_application_v2
I've given it another read. Remarks:
Positional placeholders that map to the variadic portion of the
underlying function will be named $args0, $args1, etc., and may be
called by name if desired.
What will happen if the original function already has a parameter named
$args0?
stuff($1i, $s2, $f3, $p4, $m5);
Typo: 1i.
Prefill all parameters, making a "delayed call" or "thunk"
The example desugaring is inconsistent with the previously explained
semantics: Here an arbitrary number of arguments is accepted, but
previously it says "will result in a Closure with no parameters".
// Placeholders may be named, too. Their order doesn't
// matter as long as they come after the ..., if any.
I believe this example is outdated, since the ... must come last now.
(the 's' and 'i' parameters are also missing the "number").
$c = fn(int $i1, ?float $f3, Point $p1, Point $p2): string =>
things($i1, $f3, $p1, $p2);
This example desugaring seems to be incorrect with regard to the naming
of the variadic parameters.
(four(c: ?, d: 4, b: ?, a: 1))(2, 3);
Just to spell this out explicitly: I believe this should print "1, 3, 2,
4".
$eMaker = fn(int y): E => E::make(1, $y);
`$` missing before `y`.
$c = stuff(?, ?, ?, ?, ?, ?);
The error message for this one appears to be a copy and paste error.
// throws Error(Named parameter $i overwrites previous place holder)
Is it actually "place holder" with a space?
$c = stuff(i:1, ?, ?, ?, ?);
Minor formatting nit: Missing space after colon.
$inter = fn(mixed ...$args): int => intval(..$args);
Typo: Missing dot in splat.
------
Questions:
- Are PFAs legal in constant expressions? e.g. does the following work:
`const Foo = intval(?, 10);`?
- The RFC says that it compiles down to the equivalent Closure. Can you
add an example of a stack trace for completeness? Ideally one with
SensitiveParameter working. That will then showcase the closure naming,
SensitiveParameters and that there are two stack frames for the call.
Best regards
Tim Düsterhus