Check out Dart's iterators

Brendan Eich brendan at mozilla.com
Sun Feb 10 21:36:59 PST 2013


Domenic Denicola wrote:
>> -----Original Message-----
>> From: Brendan Eich [mailto:brendan at mozilla.com]
>> 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.

/be


More information about the es-discuss mailing list