for-of loops, IteratorClose and the rest of the iterations in the spec
Boris Zbarsky
bzbarsky at mit.edu
Wed Sep 10 10:37:04 PDT 2014
On 9/10/14, 1:28 PM, Allen Wirfs-Brock wrote:
> Right, or come up with some other way to say: "this loop behaves as if it was implemented using for-of".
Thing is, for my Web IDL use case I don't want _quite_ the behavior of
for-of. I want something like this:
1. Let method be the result of CheckIterable(V).
2. ReturnIfAbrupt(method).
3. If IsCallable(method) is false, go off and do something else,
since V is not iterable.
4. Let iter be GetIterator(V, method).
5. ReturnIfAbrupt(iter).
and then IteratorStep my way through "iter".
An additional complication here is that I'm not using this in a
situation where the return value of my algorithm is an ES6 completion
(so the ReturnIfAbrupt bits above there are actually somewhat bunk; they
should be something like "if method is an abrupt completion, then
propagate method.[[value]] as an exception" or some such; we need to
figure out how to make the way DOM/IDL talk about exceptions really
interface well with the way ES does). So I'm not quite sure what
IteratorClose should actually do in my setting, assuming it should be
called at all.
-Boris
More information about the es-discuss
mailing list