Forwarding `return()` in generators

Axel Rauschmayer axel at
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list