On Tue, Jun 11, 2013 at 2:08 AM, Axel Rauschmayer <[email protected]> wrote: > On the other hand, turning every iterator into an iterable puts the burden > on people implementing iterators: they have to implement the iterable > interface.
That's... not really a burden. It's literally just adding an @@iterator method whose body is "return this;". It's the right place to put the burden, too - manual iterator authors are much, much fewer than for-of users. > And it becomes harder to distinguish the interfaces, should you > need to [1]. IMO, the purity argument also counts: this technique implies > that iterators are a subset of iterables, but that isn’t true: For > iterables, each invocation of `iterator` creates a new object, for > iterators, it doesn’t. As noted in the first comment, it's trivial to check for the difference in all well-behaved cases by just seeing if "obj === obj[iterator]()" is true or false. ~TJ _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

