[Bug 26973] make iterable declarations' iterator prototype objects inherit from %IteratorPrototype%

# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

Brendan Eich brendan@mozilla.org changed:

       What    |Removed                     |Added

             CC|                            |allen@wirfs-brock.com,
               |                            |brendan@mozilla.org,
               |                            |dherman@mozilla.com

--- Comment #1 from Brendan Eich brendan@mozilla.org ---

The plan is to put much-wanted methods on Iterator.prototype, in ES7. The iteration protocol in JS is still structural, but Iterator() provides an adapter from structural to nominal, with map/filter/etc. handy methods via prototypal inheritance.

Dave should correct me on anything amiss here. I hope this helps improve the web platform sooner.

Contact us to advertise here
# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

Boris Zbarsky bzbarsky@mit.edu changed:

       What    |Removed                     |Added

             CC|                            |bzbarsky@mit.edu

--- Comment #2 from Boris Zbarsky bzbarsky@mit.edu ---

Yeah, having generic map/filter that apply to any iterable and live on Iterator.prototype (and perhaps some prototypes of other iterables like Set and Map) would be really nice!

# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

--- Comment #3 from Brendan Eich brendan@mozilla.org --- (In reply to Boris Zbarsky from comment #2)

Yeah, having generic map/filter that apply to any iterable and live on Iterator.prototype (and perhaps some prototypes of other iterables like Set and Map) would be really nice!

Iterator not iterable, so if Map and Set have standard iterators that delegate to Iterator.prototype, then everything works automagically. You name a map or set on the right of for-of's 'of' and @@iterator does the rest.

Having Map.prototype.map do the @@iterator call and delegate to the returned iterator's map is doable but seems unnecessary when using for-of. When calling someMap.filter directly, of course, it's wanted. Some design freedom here to "do both", IMHO.

# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

--- Comment #4 from Cameron McCormack cam@mcc.id.au ---

This would mean that you would write things like:

myMap.keys().filter((x) => x > 10)

yeah? To make it a little easier to type than:

[...myMap.keys()].filter((x) => x > 10)

# bugzilla at jessica.w3.org (2 years ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

--- Comment #5 from Brendan Eich brendan@mozilla.org --- (In reply to Cameron McCormack from comment #4)

This would mean that you would write things like:

myMap.keys().filter((x) => x > 10)

yeah? To make it a little easier to type than:

[...myMap.keys()].filter((x) => x > 10)

Yes, and more efficient too.

(BTW the single-parameter arrow function form does not need parens around the formal parameter: x => x > 10 -- just passing this along in case it needs some

publicity. ;-)

# bugzilla at jessica.w3.org (a day ago)

www.w3.org/Bugs/Public/show_bug.cgi?id=26973

Domenic Denicola d@domenic.me changed:

       What    |Removed                     |Added

         Status|NEW                         |RESOLVED
             CC|                            |d@domenic.me
     Resolution|---                         |FIXED

--- Comment #6 from Domenic Denicola d@domenic.me ---

This appears to have been fixed a while ago.

Want more features?

Request early access to our private beta of readable email premium.