Re: [RFC] Auto-capture multi-line closures and short functions take 2

From: Date: Thu, 29 Apr 2021 09:49:25 +0000
Subject: Re: [RFC] Auto-capture multi-line closures and short functions take 2
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-114250@lists.php.net to get a copy of this message
On 29/04/2021 10:25, Christian Schneider wrote:
Without a keyword like "var" to declare it, I think most users would assume that an initialisation like "$foo=null;" at the top of their closure would make a variable local.
This assumption by the users would be true as we are capturing by value, not by reference.
Not entirely. As currently implemented, the value would still be captured, and so use memory, prevent destructors firing, etc. Compare 3v4l.org/Utd9j <https://3v4l.org/Utd9j> vs 3v4l.org/fpjbX <https://3v4l.org/fpjbX> Regards, -- Rowan Tommins [IMSoP]

Thread (76 messages)

« previous php.internals (#114250) next »