On Tue, Apr 1, 2025 at 12:40 PM Tim Düsterhus <t...@bastelstu.be> wrote:
>
> If you are at the point where you need mutually recursive closures,
> perhaps you should just use named functions / an anonymous class. I
> don't find it useful to “optimize DX” for that case, since
> self-recursive Closures are already somewhat questionable / rarely used
> (though I think I've used that myself a handful of times in the past).

I don't disagree. To reveal my ulterior motive: References [1].

References are used relatively rarely by PHP programmers, but they
sneak their way into many more places in the engine than you might
expect. They are also often confusing for users, bad for the
optimizer, and make implementing some highly requested features (e.g.
typed arrays) much harder.

I started collecting a list of things that require references, and
self-recursive closures is one of them.

It may be an unrealistic goal, but if we ever want to even think about
deprecating references, we'll need stable alternatives for cases where
references are currently the only viable option.

Ilija

[1] 
https://docs.google.com/document/d/1DTi4DL6wLOpDhNlmtD-G4Xr-F9oq7cTG6irK7BPxllI/edit?usp=sharing

Reply via email to