Suggestions for Set
brendan at mozilla.org
Tue Oct 2 15:55:44 PDT 2012
Domenic Denicola wrote:
> From: Rick Waldron [mailto:waldron.rick at gmail.com]
>>> This seems like an unfortunate decision, and I couldn't discern the motivation in the minutes. When would I want to use a syntax that fails for iterables? Does [...x] throw for an iterable, or result in something else?
>> The direct reasoning for the resolution was:
>> "Cannot be both iterable and array-like"
> I can't really understand what this is trying to say. It must be because I don't understand "iterable". Doesn't it just mean "responds to for-of"?
It means (in ES6, SpiderMonkey uses a string property name 'iterator')
that the object in question ("is obj iterable?) has an @iterator
property, which when called gets or creates an iterator for obj.
> I would imagine arrays, NodeLists, arguments, and other array-likes all respond to for-of; if they don't, that seriously decreases the utility of for-of!
Array.from is that an object is either iterable, or failing that,
array-like (even if no .length property, ToUint32(undefined) => 0 so no
elements). See bottom of
As Allen's followup points out, array iteration skips holes, to match
Array.prototype.forEach. Should spread fill holes or skip them?
>> It's possible that this could be added to the agenda for november, if Brendan wants to discuss SpiderMonkey's experience implementing it. It seems to me that if they're not having issues then it's at least worth a mention.
I actually do not remember why we went back to only array-like instead
of iterable || array-like for spread. Can someone (Rick? Dave? Arv?) recall?
More information about the es-discuss