Final iterator spec

Andy Wingo wingo at
Mon Mar 3 04:56:12 PST 2014

On Mon 03 Mar 2014 12:49, Claude Pache <claude.pache at> writes:

> Le 3 mars 2014 à 10:46, Andy Wingo <wingo at> 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:

Then there are is the "next" operation on iterators:

...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


More information about the es-discuss mailing list