In the following example:
```js
function* foo() {
try {
yield 1;
} finally {
cleanup();
}
}
(function() {
var f = foo();
f.next();
// never reference f again
})()
```
- Is the iterator created by the function `foo` ever eligible for garbage
collection?
- If it is - does it run the `finally` blocks?
Related resources:
- Python changed the behavior to "run `return` on gc" in 2.5
https://docs.python.org/2.5/whatsnew/pep-342.html
- C# doesn't run finalizers, but iterators are disposable and get aborted
automatically by foreach (for... of) - on break. this is similar to what we
do:
http://blogs.msdn.com/b/dancre/archive/2008/03/14/yield-and-usings-your-dispose-may-not-be-called.aspx
- PHP is debating this issue now, I was contacted by PHP internals people
about it which is how I came into the problem in the first place:
https://bugs.php.net/bug.php?id=71604
- Related issue I opened on async/await :
https://github.com/tc39/ecmascript-asyncawait/issues/89
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss