The ES6 iteration protocol
Dmitry Soshnikov
dmitry.soshnikov at gmail.com
Mon Apr 6 21:30:39 UTC 2015
Exactly, that's what I tried to explain. Since in one case it considers
just an iterable (an array), and in other case -- an iterator (which is by
"coincidence" is also an iterable). But an array's iterator is an iterable
as well, and also always returns itself for iterator protocol.
Yeah, the "self-iterable" makes much more sense in this case.
Dmitry
On Monday, April 6, 2015, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>
> > On Apr 6, 2015, at 2:23 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com
> <javascript:;>> wrote:
> >
> > I guess all built-in iterators return themselves for `Symbol.iterator`
> protocol. So they are all "singletons". I described in detail where
> confusion/substitution of concepts happens in that analysis in the recent
> two comments.
> >
>
> I don’t think “singleton” is the correct term for the concept that Axel is
> trying to describe. A “singleton” is normally an kind of object for which
> there is only a single instances. There may be many instances of, for
> example %ArrayIterator%, so it isn’t correct to call %ArrayIterator% a
> singleton
>
> What Axel is describing might be characterized as “self iterable”, it
> returns itself when recieving a Symbol.iterator request.
>
> Allen
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150406/fe24a6df/attachment-0001.html>
More information about the es-discuss
mailing list