StopIteration, ForwardToTarget, ... & symbols
brendan at mozilla.org
Tue Nov 27 10:06:45 PST 2012
David Bruant wrote:
> I'm not sure I understand your reluctance to symbols.
Because an object has unique identity, and StopIteration is a
constructor, it can't be a symbol.
> I have been thinking more about it, because "throw StopIteration"
> feels a bit like a hack in the sense that the goal is not to throw an
> error. Actually, it's already known in the iterator protocol that the
> error will be caught by the direct caller (the JS engine).
Known at runtime.
> What we need is a way to end a frame in a way that unambiguously
> signifies that the iteration stops. The Legitimate Way™ would be to
> add a new "stopiteration [reason];" statement to end a frame.
I don't know what you mean. The problem is not static, however, so not
local. In the case of task.js for example, the thrown StopIteration must
be caught explicitly and the yield from which a resumed generator throws
might be delegated (yield*).
More information about the es-discuss