+1. When reading the draft and spontaneously discovering this wierdness I was 
extremely surprised.

That said, Set is shipping in every major browser so it's not going to get 
fixed now.
________________________________
From: Dmitry Soshnikov<mailto:[email protected]>
Sent: ‎2014-‎10-‎10 18:56
To: es-discuss<mailto:[email protected]>
Subject: Set API

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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to