Questions/issues regarding generators

Andreas Rossberg rossberg at
Thu Mar 14 15:31:20 PDT 2013

On 14 March 2013 22:54, Brendan Eich <brendan at> wrote:
> Consider:
>     var i = getSomeIterator();
>     var x0 =, x1 =, x2 =;
>     for (let x of i) {
>         ...
>     }
> Should the loop iterate over x0, x1, and x2? That's what would (have to)
> happen if i[@iterator]() returned a cloneof the iterator ireset to the
> starting "position".

I agree this is an unsatisfactory consequence to the
generatorObject.iterator = cloning proposal, which was meant as a kind
of have-your-cake-and-eat-it-too compromise. It doesn't really achieve
that, so I withdraw it.

That leaves my original proposal not to have generator application
return an iterator, but only an iterable. Under that proposal, your
example requires disambiguation by inserting the intended call(s) to
.iterator in the right place(s).


More information about the es-discuss mailing list