Andreas Rossberg (2013-06-12T16:14:57.000Z)
github at esdiscuss.org (2013-07-12T02:27:37.718Z)
On 12 June 2013 14:12, Claude Pache <claude.pache at gmail.com> wrote: > Well, as currently specced, the operation that serves as `ToIterator` conversion meta function is: > > itr => itr[@@iterator]() > > If I understand you correctly, you propose that it should be changed to: > > itr => @@iterator in itr ? itr[@@iterator]() : itr > > The only place where it would simplify programmers' life, is where they try to define manually an iterator, which I expect to be quite rare. Maybe, but it's a simplification nevertheless. Moreover, removing a concept as such reduces cognitive load for everybody. Mind you, these advantages are minor. > On the other hand, I see a small advantage of the "weird" requirement for iterators to be iterables themselves: It allows to discriminate between true iterators and merely "nextable" objects. And in the spirit of "duck typing", why would you want to do that? And how do you want to treat an iterable with a 'next' method, but whose @@iterator method does not return 'this'? Is that a "true" iterator? (The fact that such a beast can even exist shows how fuzzy those notions are.)