Re: RFC: Support Closures in constant expressions

From: Date: Wed, 30 Oct 2024 08:31:03 +0000
Subject: Re: RFC: Support Closures in constant expressions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-125877@lists.php.net to get a copy of this message
On Wed, Oct 30, 2024 at 10:03 AM Tim Düsterhus <tim@bastelstu.be> wrote: > Hi > > Am 2024-10-30 05:25, schrieb Larry Garfield: > > This seems like a good idea to me. My only real question is why we > > need to forbid short-closures. I fully agree that capturing variables > > for such functions doesn't work. What I don't understand is why that > > precludes short-closures. Is it not possible to "just" say "there's > > nothing to even capture in this context, don't try"? (There may be > > technical reasons for that, but I do not know what they are and the RFC > > doesn't say.) > > It would indeed require some special handling to disable the > auto-capturing in the code. This would be solvable of course, but > there's also semantic ambiguity, because users reasonably expect short > closures to perform auto-capturing: > > Hi Tim, So, why not allow capturing, since anyway the only place to capture are constants and static variables? And this way we could have short closures with auto-capture. If there are some technical reasons for not doing that, can we have written in the RFC? Alex

« previous php.internals (#125877) next »