On Friday, October 10, 2014, Dmitry Soshnikov <dmitry.soshni...@gmail.com <javascript:_e(%7B%7D,'cvml','dmitry.soshni...@gmail.com');>> wrote:
> Hi, > > (sorry I again probably too late, if the API is already locked, very > likely it has been discussed and approved, please let me know) > > The API of `Set`s seems in inconvenient way exposes things that relates > only to implementation details, but which doesn't make big sense at > abstraction usage level. > > In particular, the `keys` and `entries` methods. I understand that `Set`s > are just backed by `Map`s, and for simplicity of the specification reuse > the same iteration algorithms (which by default calls `entries` for maps in > `for-of`). > > But `keys` just doesn't make sense for sets, and the most inconvenient is > callback function for `forEach` (and later for `map` and `filter` when they > will be introduced). If devs want to analyze the set object itself, they > have to repeat twice the "value" in parameters. > > ``` > (new Set([1,2,3])).forEach((value, againValue, theSet) => { > // huh? againValue? > ... > }); > ``` > The designed to match A.p.forEach parameters to reduce refactoring hazards. Rick > Are we OK with this? Seems like removing `entries`, `keys` and providing > own default `@@iterator` for `Set` which should be just `values()` would > make it more sense from the abstraction usage perspective. > > Dmitry >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss