Hi
Am 2024-10-31 07:16, schrieb Larry Garfield:
Hm. It would never occur to me to use a function for a non-class
constant in the first place, so I don't know. :-) Frankly I can't
recall the last time I used a non-class constant period. :-)
That said, PHP consts are already a bit squishy, and auto-capture is
always by value. That wouldn't give us a loophole?
Here's another brainteaser:
function foo(
string $bar,
Closure $baz = static fn () => $bar,
) {
var_dump($baz());
}
foo('captured');
What would you expect the semantics of that script to be?
If it cannot reasonably be done now, but is possible, that should be
listed in future scope with roughly what it would take for a follow-up
to do. (And then we can argue if it should just be done now, with more
information as to how much work that is.)
I have added an entry to the “Future Scope” section. See also my reply
to Alex.
Best regards
Tim Düsterhus