Hi Nikita,

On 08/06/12 13:16, Nikita Popov wrote:
On Wed, Jun 6, 2012 at 12:20 PM, Ivan Enderlin @ Hoa
<ivan.ender...@hoa-project.net> wrote:
In addition to Gustavo's remarks, I wonder how the GC would collect a
Generator object that is not use anymore (especially with a referenced
yield). Does it fit to the current CG strategy or do we need an extra
strategy? I would notice that the “Yield by reference” section does not
exist but you have targeted it).
I added a new section which answers the question at least partially:
https://wiki.php.net/rfc/generators#closing_a_generator
Good. Thank you.

If you don't need the generator object anymore you can either
explicitly ->close() it or wait until all references to it are removed
(typically when leaving the scope of the calling function). When the
generator is closed it releases all used resources, including the
suspended execution context and the currently yielded value. Whether
or not the value is yielded by reference shouldn't make a difference.
So, yes, the current GC strategy works well for generators too :)
Ok. A very naive question: would it be interesting to make the difference between a “yield” and a “weak referenced yield values” (same concept that https://wiki.php.net/rfc/weakreferences which is under voting phase as the RFC said).

Thank you for your clarifications.

--
Ivan Enderlin
Developer of Hoa
http://hoa.42/ or http://hoa-project.net/

PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis)
http://disc.univ-fcomte.fr/ and http://www.inria.fr/

Member of HTML and WebApps Working Group of W3C
http://w3.org/



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to