Creating and consuming custom iterators
# Axel Rauschmayer (12 years ago)
There will be a public symbol (that you can import from a system module) that will allow you to do both things.
# medikoo (12 years ago)
There's no problem then. Thanks
There will be a public symbol (that you can import from a system module) that will allow you to do both things.
> 1 There's no way I can create custom iterator abstraction (How can I can > define MyCustomIterator.prototype[@@iterator] method?). > > 2. There's no straightforward way to consume iterators in generic way, e.g. > I want to write function that works in similar way as Set constructor, and > accepts any iterator implementation. I don't have a means to call > iterator[@@iterator] method. > > Please correct me if I'm wrong, but if it's the case, I think it's really > important to open that. > > Maybe there should be Reflect.getIterator(obj) and > Reflect.defineIterator(obj, getIterator) for that? There will be a public symbol (that you can import from a system module) that will allow you to do both things. -- Dr. Axel Rauschmayer axel at rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130828/589173d7/attachment-0001.html>
There's no problem then. Thanks
> There will be a public symbol (that you can import from a system module) that will allow you to do both things. There's no problem then. Thanks -- View this message in context: http://mozilla.6506.n7.nabble.com/Creating-and-consuming-custom-iterators-tp289598p289600.html Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
In ES5 there is a concept of array-like, which while probably too relaxed is really friendly for developers, as we can easily create custom array-like abstractions and make it consumable to any generic functions, methods that process array-likes.
In ES6 there's more advanced (and definitely better) iterators concept, while I'm pretty excited by it, If read spec correctly I see it's quite limited and not that usable.
There's no way I can create custom iterator abstraction (How can I can define
MyCustomIterator.prototype[@@iterator]
method?).There's no straightforward way to consume iterators in generic way, e.g. I want to write function that works in similar way as Set constructor, and accepts any iterator implementation. I don't have a means to call
iterator[@@iterator]
method.Please correct me if I'm wrong, but if it's the case, I think it's really important to open that.
Maybe there should be
Reflect.getIterator(obj)
andReflect.defineIterator(obj, getIterator)
for that?