Check out Dart's iterators

Domenic Denicola domenic at
Sun Feb 10 21:40:28 PST 2013

> From: Brendan Eich [mailto:brendan at]
> Domenic Denicola wrote:
> >> -----Original Message-----
> >> From: Brendan Eich [mailto:brendan at]
> >> Sent: Sunday, February 10, 2013 03:20
> >
> >> Changing from hasMore/getNext to current/moveNext does not eliminate two methods that can get out of sync. You can imagine one is a property, not a method, but the general case is a getter or C#-style Current method.
> >
> > Ah, the fact that it could be a getter does reduce it to the original two-out-of-sync-methods case, right. Thanks!
> Rather, current *must* be a getter (or really, a method). The iteration protocol abstracts over all implementations using structural type(s), where the signature(s) must be the same for all iterators. Not all iterators want to expose a writable data property, .current.
> Or did you mean a non-configurable, non-writable data property named current that is updated by moveNext? That would make all iterators be exotic objects, which is a non-starter.

I don't see why all iterators would have to have the same "kind" of property descriptor? I.e. if one iterator wanted a getter, and others wanted a writable, configurable data property, what's the problem there? It seems your structural type(s)/signature(s) comment is heading in this direction, but I don't understand why.

More information about the es-discuss mailing list