W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2015

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

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Thu, 29 Oct 2015 10:57:51 -0400
To: Cameron McCormack <cam@mcc.id.au>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <563233EF.8080306@mit.edu>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC