Re: Compact can't resolve outer scoped variables using short closures

From: Date: Thu, 20 Oct 2022 17:03:02 +0000
Subject: Re: Compact can't resolve outer scoped variables using short closures
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-118861@lists.php.net to get a copy of this message
On 20/10/2022 17:48, David Rodrigues wrote:
Regarding this, in case you're literally saying that internally "fn()" turns into a common "function", and getting back to the main topic, would it be possible to do the same with compact()? fn() => compact('dummy') turns into: fn() => [ 'dummy' => $dummy ] which turns into: function() use($dummy) { return [ 'dummy' => $dummy ]; }
Yes, that is what I meant by "it would be possible for the compiler to special-case this scenario"; I explained why I think that would be a bad idea, and suggested an alternative. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#118861) next »