>> But: you need to guard against other ways of reaching `finally`. > > Why? I intended to always reach finally, and always close the iterator. Also, > simplicity ftw :-) > > > That’s not what all the other constructs in ES6 do: they only call > > `return()` if iteration stops abruptly. > > Only because all the other constructs in ES6 try to exhaust the iterator. And > when it's finished anyway, one doesn't need to close it. > There is in fact no problem with calling `.return()` too often, it just > doesn't do anything to completed generators.
True. I hadn’t thought of that. > Btw, your `take` function is the perfect example where a non-exhausted > iterator *should* be closed as return prematurely - like a `break` in a > for-of loop would. Right. Always closing is much simpler. Otherwise, you’d have to check whether everything was exhausted or not. -- Dr. Axel Rauschmayer a...@rauschma.de rauschma.de
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss