Iterators, generators, finally, and scarce resources (Was: April 10 2014 Meeting Notes)

C. Scott Ananian ecmascript at
Wed Apr 30 07:26:22 PDT 2014

Domenic: the argument against is that changing the semantics of `for of` --
and all of the standard library methods, in the case of exceptional exit --
would result in a user-visible change to the state of the iterator.  That
is, the iterator would not be closed, whereas ES6 as it stands now would
let you continue iteration.

The various proposed deferrals don't prevent the user from observing a
different iterator state.

The only working deferral I can think of is to remove `for of` from the
spec entirely, and prevent most methods from taking `Iterators` as
arguments (since the completion state of the `Iterator` would change in
ES7).  You might be able to get away with taking `Iterable`s as arguments,
even though the user could (for example) abuse the `Iterable` interface to
return a singleton `Iterator` and thus observe its state.  But they'd have
to work hard to subvert the spec that way.  This 'deferral' would be a huge
change to the spec, but once would expect most implementors to ignore the
neutered ES6 spec and just implement ES7 iterators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list