Re: What are the desired semantics of forEach for iterables?

On 10/29/15 2:40 AM, Cameron McCormack wrote:
> We might consider the fact that we have both iterable<> and setlike<>. If we have an object that behaves like a Set, then we should make it setlike<> rather than iterable<>. So if iterable<> is for more list-like things, I think it could make sense to invoke forEach like Array does.

OK.  Again, it's hard to say what the use cases are here, exactly, 
because we don't have any so far as far as I can tell...

One option is to just disallow one-type iterables on anything without an 
indexed getter for now, spec that case to be just like Array (indeed, we 
can simply reuse Array.prototype.forEach, I would think), and add a note 
that if someone wants one of those at some point we'll examine the use 
case then.

> No strong opinion except to say that for a one-type iterable, we should probably do (b) if we make forEach behave like Set’s forEach.

Note that IDL setlike has behavior (a) as specified right now, even 
though its forEach acts like Set's forEach in terms of what it passes in...

-Boris

Received on Thursday, 29 October 2015 14:58:26 UTC