Why can’t for-of be applied to iterators?

Brendan Eich brendan at mozilla.com
Wed Jun 12 10:51:59 PDT 2013

The @iterator part of the iteration protocol is not about coercion or 
types at all. It is a "pattern" for getting or creating a usable 
iterator from an object.

In this light, ToIterator is the wrong name. GetIterator (see C#) is better.


Allen Wirfs-Brock wrote:
> Personally, I don't really think about  what is going on here as a type coercion  but I have no problem if you what to explain it as applying ToIterator.  It may even be useful to use this in the spec.

More information about the es-discuss mailing list