Immediate closing of iterators

Chris Hansen renselp at
Wed Dec 20 03:02:55 PST 2006

>> So, could the spec require Javascript to always close the iterator
>> when leaving a loop?
> So long as it's a non-escaping generator-iterator created by the
> loop, then the spec could mandate that.  It requires some extra work
> by non-reference-counting implementations.  They need to keep track
> of such generator-iterators across nested loops in each live function
> or script activation, and close each generator-iterator as control
> exits its loop.

Unless the definition of "created by the loop" is very strict won't
this effectively mandate a full GC whenever you leave a for-in loop?
Even reference counting implementations would have to detect
unreachable cycles in the object graph.

-- Chris

More information about the Es4-discuss mailing list