Iterators, generators, finally, and scarce resources (Was: April 10 2014 Meeting Notes)
Mark S. Miller
erights at google.com
Wed Apr 30 07:34:59 PDT 2014
I'm not concerned about manually added .return methods, nor manual calls to
.return methods, though perhaps I should be. If this is a concern, we could
solve it by using an @return symbol in ES7 rather than a string name.
Neither am I concerned about system iterators, assuming that none of the
system iterators needs a .return method, which depends on Andreas' response
to my question.
Rather, I am concerned specifically about the interaction of for/of and
generators, even in the absence of any finally clauses in the generator
code. If the for/of exits early, under this proposal, the generator will be
put into a non-resumable state. In current ES6, the generator is resumable.
If ES6 ships with the generators resumable under these conditions, I doubt
we will dare make them non-resumable in ES7.
On Wed, Apr 30, 2014 at 7:26 AM, C. Scott Ananian <ecmascript at cscott.net>wrote:
> 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.
> --scott
>
>
--
Cheers,
--MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140430/862f8c7b/attachment.html>
More information about the es-discuss
mailing list