Check out Dart's iterators

Brendan Eich brendan at mozilla.com
Sun Feb 10 21:25:41 PST 2013


This is exactly what's proposed for ES6, except s/.source/.value/. See 
also PEP-380.

/be

Claude Pache wrote:
> In order to mitigate the problem, instead of throwing a generic StopIteration, I think we ought to throw a specific StopIteration instance with information on which iterator has thrown. More precisely, inside a generator function, a return statement will throw a StopIteration instance with its "source" property set to the generator iterator which was terminated.
>
> For manually throwing a StopIteration from inside a "next" method of an iterator, we could use:
>
> 	throw new StopIteration(this)
>
> And instead of "e instanceof StopIteration", we may use a more precise check:
>
>      e instanceof StopIteration&&  e.source === it


More information about the es-discuss mailing list