On Sun, Oct 12, 2025, at 1:35 PM, Tim Düsterhus wrote:
> Hi
>
> On 10/10/25 17:26, Larry Garfield wrote:
>>> What will happen if the original function already has a parameter named
>>> $args0?
>>
>> It will skip over existing names. I've updated the text accordingly.
>
> Okay. Looking at all the examples, I think it would be nice if it would
> not use the generic arg prefix, but use the original name as the
> prefix. For the
>
> function foo(int $a = 5, int $b = 1, string ...$c) { }
>
> example, the 3rd and following parameters could be $c_1, $c_2, …
> (still skipping over duplicates).
OK, there was a miscommunication between Arnaud and I. It is using the variable name, not
"args" already. Just with no _ and 0-based. I've updated the RFC accordingly.
> Okay. Now looking at the examples:
>
> $c = stuff(?, ?, f3: 3.5, p4: $point, ...);
> $c = fn(int $i1, string $s2, int $m5 = 0): string => stuff($i1,
> $s2, 3.5, $point, $m5);
>
> and
>
> $c = stuff(1, 'hi', 3.4, $point, 5, ...);
> $c = fn(...$args): string => stuff(1, 'hi', 3.4, $point, 5, ....$args);
>
> seem to be inconsistent with each other with regard to whether or not
> "superfluous" arguments are passed through.
>
> This might (or might not?) be explained in the “func_get_args() and
> friends” section, but is unexplained at the point the example appears.
> Also within the func_get_args() section, there is no explicit ...$args
> in the resulting signature, but instead the desugaring uses
> array_slice() + func_get_args().
We talked a bit more, and decided to tighten the rules further. I've updated the RFC
accordingly. Essentially, the first example is correct, the second has been changed.
If the underlying function is variadic, and ... is used in the PFA, then it will accept an arbitrary
number of arguments. In any other case, only explicitly-specified arguments will be passed through.
> Thank you, I'm seeing you added an example. I've a small request to
> hopefully make the example more useful: It currently uses only
> “placeholder” parameters. It would be useful to also add one pre-filled
> parameter to it. I would assume that this pre-filled parameter does not
> appear within the Closure frame, but appears with the frame for the
> actual function?
Updated the error dump example.
> - How does it interact with compact(), specifically:
>
> $partial = compact(someValue(), ?);
>
> Would the ? be able to capture a variable containing the return value
> of someValue()?
Good question! compact(), extract(), etc. can't actually work with PFA, because they operate
on the ambient context, which PFA by design changes. I've updated the RFC to note three
incompatible core functions. (The other is func_get_arg()).
--Larry Garfield