Re: [PATCH] [RFC] Closures and lambda functions in PHP

From: Date: Thu, 26 Jun 2008 08:13:22 +0000
Subject: Re: [PATCH] [RFC] Closures and lambda functions in PHP
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-38629@lists.php.net to get a copy of this message
On Jun 26, 2008, at 4:06 AM, Lukas Kahwe Smith wrote:
Now, upon execution of the code containing the closure, the new opcode just copies the zend_function structure into a copy, registers that copy as a resource and returns that resource. As soon as the resource is garbage collected (or explicitly unset), the op_array copy is destroyed. No modification of the actual class is done at all - the cache remains happy.
So since a reference is stored, it means that the destructor of the enclosing object is only called once not only the variable holding the object, but also all lambda functions that were created inside of the class have been free'ed?
I'm not up to date on the operation of the current patches to implement closures, but typically this is how it'd work, retaining references to what's needed as long as the closures exist. -- Gwynne, Daughter of the Code "This whole world is an asylum for the incurable."

« previous php.internals (#38629) next »