On Mon 03 Mar 2014 12:49, Claude Pache <[email protected]> writes:
> Le 3 mars 2014 à 10:46, Andy Wingo <[email protected]> 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? For what purpose? You rightly link to the denotation of Iterable; in context, it is used like this: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-getiterator Then there are is the "next" operation on iterators: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-iteratornext ...and reading that I see that my memory was off, that we don't fetch the "next" method eagerly, and instead look up the "next" property each time. Apologies for the misinformation. Thus you can: function *g() { Object.defineProperty(g.prototype, 'next', {value:42}); yield 4; } for (var x of new g()) print (x); The iterator is indeed an iterator when it is returned by @@iterator, but not after the first iteration :) Basically: you are looking for looking for certainty in structural typing of mutable values. You won't find it; or rather, if you do find it, it lasts only until the next piece of code that could mutate the world. Andy _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

