>> Right. Always closing is much simpler. Otherwise, you’d have to check >> whether everything was exhausted or not. > > This is by design, FWIW.
Which is OK, I’m more worried about generators behaving differently in reaction to `return()` than, e.g., array iterators. With the latter, you can continue iterating if you break from a `for-of` loop, with the former, you (generally) can’t. Either behavior is OK, but it should be consistent: Is `return()` for optional clean-up (array iterators) or does it really close an iterator (generators)? The way that `return()` is handled in generators (via try-catch) means that the clean-up action is called in both cases: generator exhaustion and generator closure. If you don’t use a generator then a clean-up action in `return()` is only called if the iterator is closed, not if it is exhausted. Obviously that is a minor technical detail and easy to fix (call the clean-up action when you return `{ done: true }`), but it’s still an inconsistency (which wouldn’t exist if `return()` was called in either case). -- Dr. Axel Rauschmayer a...@rauschma.de rauschma.de
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss