Default iterator

Erik Arvidsson erik.arvidsson at gmail.com
Wed Jun 20 21:37:09 PDT 2012


Jason Orendorff updated the iterator proposal a bit. Thank you Jason.
I'd like to point out an issue with it though.

In our previous discussion I had come to the understanding that the
default iterator would use a private name. The main benefit for using
a private name is to not pollute the property name space.

import iterator from '@iter';
myObject[iterator] = function*() { ... };

If this was the ordinary property, "iterator", it might break existing
code that already use "iterator" in some other way.

var obj = LibraryX.getObject();
obj.iterator().forEach(...);

It also breaks objects as maps since any string can be used as key.

-- 
erik


More information about the es-discuss mailing list