Final iterator spec

Claude Pache claude.pache at gmail.com
Mon Mar 3 03:49:53 PST 2014


Le 3 mars 2014 à 10:46, Andy Wingo <wingo at igalia.com> a écrit :

> 
> An iterable is simply an object with a callable @@iterator property.
> Calling @@iterator on an object and getting back a result is the
> sum-total of the iterator structural type -- so yes, this problem is
> solved.

What does exactly the spec think what an iterable is? As far as I can tell, only `Array.from` and `%TypedArray%.from` test for iterability, and until [bug 2486] is resolved, it is hard for us to guess, because there are really more than one possible answer, e.g.: `Symbol.iterator in obj` and `typeof obj[Symbol.iterator] === "function"`. 

Section The Iterable Interface [1] define something more restrictive than `typeof obj[Symbol.iterator] === "function"`` and less testable, given the requirements of the returned value of `obj[Symbol.iterator]()`.

—Claude

[bug 2486] https://bugs.ecmascript.org/show_bug.cgi?id=2486
[1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iterable-interface


More information about the es-discuss mailing list