Dmitry Soshnikov
2014-10-10 22:56:01 UTC
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?
...
});
```
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141010/84aa92dd/attachment.html>
(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?
...
});
```
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141010/84aa92dd/attachment.html>