Code smell? Iterator prototype has iterator method that returns "this"
John Lenz
concavelenz at gmail.com
Mon Jul 25 23:38:05 UTC 2016
Yes, but at the cost of being able to reason / declare what kind of object
is actually required. But, I'm sure there is nothing that can be changed
here.
On Mon, Jul 25, 2016 at 4:31 PM, Tab Atkins Jr. <jackalmage at gmail.com>
wrote:
> On Mon, Jul 25, 2016 at 4:28 PM, John Lenz <concavelenz at gmail.com> wrote:
> > I understand the way it is used, but I don't understand why. "for-of"
> > could have been spec'd to take either an Iterable (an object with an
> > [Symbol.iterator] method) or an Iterator. Or just an Iterable.
>
> Not just for-of, but the whole rest of the world (in particular,
> anything that directly consumes iterables) would also have to make
> that distinction. Much easier to just let everyone pretend that an
> iterator is iterable, so you can use a common API between the two
> types. (Also, Python already worked this way, and a lot of JS
> iterator details were copied from Python originally.)
>
> ~TJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160725/00d62207/attachment.html>
More information about the es-discuss
mailing list