Hi

Am 2025-01-31 23:36, schrieb Larry Garfield:
Purely out of curiosity and for educational value, what was so complicated about it? I would have expected it to be straightforward.

FCC internally are effectively treated as function calls with a funny parameter list. This means that all valid ways to perform a function call are valid ways to create a FCC. And likewise do all constraints of a function call also apply to creating a function call. FCCs in const-expr need to replicate those semantics as applicable. For us this means: A FCC in a parameter default value behaves, as if the assignment was the first line in the function body. Likewise must a FCC in a property default value behave as if it was assigned in the first line of the constructor body.

And then amongst others you have the following (edge-)cases to take into account:

- All kinds of expressions can be used as a function name (this RFC excludes those for simplicity). - A FCC can resolve to a dynamic function when __call() or __callStatic() is implemented (this RFC excludes those for simplicity). - Static methods can directly be called on a trait (this is deprecated, but supported by the RFC). - Calls to free-standing functions need to take the global namespace fallback into account (which will be cached for each individual call, which has funny effects when the function in the same namespace gets defined after some of the calls already executed at least once). - Visibility and names needs to be resolved correctly, including references to `self` and `static`.

For regular closures (i.e. the first RFC) it was as simple as: Disallow `use` and require `static` and you're done. They are much less context-dependent.

Best regards
Tim Düsterhus

Reply via email to