Re: [webidl] Fix some problems with iterable declarations. (#72)

>                      <li><a href="#es-invoking-callback-functions">Invoke</a> <var>callback</var> with <var>thisArg</var>
>                        as the <a class="dfnref" href="#dfn-callback-this-value">callback this value</a> and
> -                      <var>k</var> and <var>value</var> as its arguments.</li>
> +                      <var>value</var>, <var>key</var> and <var>O</var> as its arguments.</li>
> +                    <li>Update <var>pairs</var> to the current list of <a class="dfnref" href="#dfn-value-pairs-to-iterate-over">value pairs to iterate over</a>.
> +                      <div class="note"><div class="noteHeader">Note</div>
> +                        <p>Depending on whether prose accompanying the interface defined this to be a snapshot at the time

> And in any case pairs could be removed and re-inserted at later indexes and be iterated over multiple times

Yep.  I think the same can happen with Map/Set, actually.  For example, this script:

    var s = new Set([1, 2, 3]); 
    var e = s.values(); 
    console.log(e.next()); 
    s.delete(1); 
    s.add(1); 
    console.log(...e)

logs:

    Object { value: 1, done: false }
    2 3 1


> I can't see why there'd be good reasons to choose differently for different APIs.

Well, performance and simplicity, possibly.

But yes, we could do what you suggest.  I don't believe it would match the Map/Set behavior, though, per above.

---
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/72/files#r45026919

Received on Tuesday, 17 November 2015 06:49:12 UTC