- From: Boris Zbarsky <bzbarsky@mit.edu>
- Date: Tue, 10 Nov 2015 17:05:35 -0500
- To: Domenic Denicola <d@domenic.me>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 11/7/15 4:08 AM, Domenic Denicola wrote: > - Assume that if an indexed getter is present, the object is array-ish, so the (value, index, this) signature will be used. Otherwise assume it's set-ish, so use (value, value, this). > > I admit though that the existence of set-ish but not setlike<> interfaces is speculation at this point. (Although, DOMTokenList...) Which acts Array-ish in the one impl that has forEach on it, right? > So maybe we should just go with (value, index, this) always. What I would like to propose is that we only allow one-type iterables on things with an indexed getter for now, make it clear that once we have a concrete use case for something else we will figure out how it should work (so people who have such a use case will tell us about it), and for the "one-type iterable with indexed getter" case use Array-ish behavior. >> 3) How should deletion and addition during iteration, especially deletion be handled? The two possible answers are: > > I don't have a real opinion on this and would be happy to go with whatever's simpler to implement or results in a faster forEach method for authors. What's simpler/faster to implement is just incrementing an index and possibly skipping things if deletions happen during forEach. That, incidentally, makes forEach match what the actual iterator does (as specced at the moment) if you delete things in between calls to next(). Again, this matches how Array works, but not Set and Map... But clearly I'm fine with the simpler to implement thing. ;) -Boris
Received on Tuesday, 10 November 2015 22:06:04 UTC