>
> I should have said, "when for-of" invokes the close method, because of an
> exception and the close produces a different exception.
>

Ah yes.  I think those semantics, as currently specified, are right on.

So what would we expect an inner iterator to do, if it supports "return"
but not "throw"?  What would an equivalent "throw" method, in such a
situation, look like?

If it doesn't have a "throw" method then that means that it cannot usefully
process errors.  One generator function which fits that description might
be:

    function* a() {
        try {
            yield 1;
        } finally {
            print("cleanup");
        }
    }

If we call "throw" on a generator produced by this function (when the
generator is paused within the try block), the finally block will run and
then the thrown exception will propagate back to the caller.

So it seems to me that not having a throw method should be equivalent to
something like:

    throw(value) {
        var r = this.return;
        if (r !== undefined)
            r.call(this);
        throw value;
    }

But I can see the argument for a TypeError (and not calling "return") as
well.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to