Forwarding `return()` in generators

Axel Rauschmayer axel at rauschma.de
Fri Mar 27 00:01:46 UTC 2015


>> It’d be great if all iterables were indeed the same in this regard.
> 
> What do you suggest, that array iterators should not be continuable? So we'd have `.return()` methods on ArrayIterators, StringIterators, MapIterators, and SetIterators, which sets the respective [[Iterated*]] internal property to `undefined`?

Maybe I overstated, maybe documenting whether an iterable produces continuable iterators is enough, but it is something to be aware of, something that has to be explained in conjunction with the iteration protocol. Similarly: whether an iterable restarts iteration every time you call `[Symbol.iterator]()` (generators don’t restart, arrays do).

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
rauschma.de



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150327/a35ecffd/attachment.html>


More information about the es-discuss mailing list