Re: [RFC] Partial Function Application v2
| From: | Larry Garfield | Date: | Fri, 10 Oct 2025 15:26:44 +0000 |
| Subject: | Re: [RFC] Partial Function Application v2 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128811@lists.php.net to get a copy of this message | ||
On Thu, Oct 9, 2025, at 4:39 PM, Tim Düsterhus wrote:
> 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?
It will skip over existing names. I've updated the text accordingly.
>> 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".
Hm, I think that should probably read "no required parameters". It would only make a
difference if the underlying function had an optional variadic AND you called the thunk with extra,
extraneous args.
*Various typos fixed along the way*
> ------
>
> Questions:
>
> - Are PFAs legal in constant expressions? e.g. does the following work:
>
const Foo = intval(?, 10);?
At the moment no, though Arnaud says that should be doable, with some reasonable restrictions. (No
variables, no variable callable name, etc.)
> - 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
I've asked Arnaud to generate one for the RFC.
--Larry Garfield