From: Brendan Eich [mailto:[email protected]] 

> But entries returns an iterator, and if we define %IteratorPrototype% to 
> create a new instance of the right class given its |this| parameter, in this 
> case Map and not MapIterator, then no need for the new Map() wrapper.

This seems like it'd involve too much machinery and give unexpected results.

I'd expect `instance.map(...)` to return another one of `instance`. That is, 
given a MapIterator `i`, I'd expect `i.map(...)` to be another MapIterator, and 
not a Map like you are proposing.

Giving a MapIterator also has the advantage of preserving laziness. I like how 
in 

> ```js
> var newMap = new Map(oldMap.entries().map((([k, v]) =>  [k + 1,  v+ 1]);
> ```

The Map constructor call gives a clear delineation of where the iterator is 
being consumed, and the laziness is flattened down. Whereas if 
`.entries().map(...)` gave a Map instance straightaway, the option of keeping 
things lazy would be gone.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to