I believe Iterator should be an interface and not a class so I could extend Array or ArrayLike implementing Iterator, when/if necessary, in order to have a for/of compatible class.
We don't have interfaces ... I know, we could have mixins though, compatible with @@things too. My 2 cents On Tue, Jun 11, 2013 at 9:41 AM, Brandon Benvie <[email protected]> wrote: > On 6/11/2013 5:50 AM, Tab Atkins Jr. wrote: > >> 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. >> > > It may be worth noting that, while it hasn't made it into the ES6 spec > (yet?), the iterators strawman [1] (and modules_standard strawman [2]) had > an `Iterator` class that all the builtin iterators (Map, Set, Generator, > etc.) inherited from who's prototype had @@iterator built in. So usually > the only burden for iterator authors was to create a class that inherited > from Iterator. > > import { Iterator } from '@iter'; > class MyIterator extends Iterator { /*...*/ } > > > [1] > http://wiki.ecmascript.org/**doku.php?id=harmony:iterators<http://wiki.ecmascript.org/doku.php?id=harmony:iterators> > [2] > http://wiki.ecmascript.org/**doku.php?id=harmony:modules_**standard<http://wiki.ecmascript.org/doku.php?id=harmony:modules_standard> > > ______________________________**_________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss> >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

