Axel Rauschmayer wrote:
We could definitely have Map and Set literals:
const map = {1 => "one", "two" => true, false => "three"};
Would that be tricky to parse if keys can be arbitrary expressions
(incl. array literals)?
The issue would be arrow function expression keys:
const map = {x => x*x => "square"};
But such a key could not be found without capturing the reference:
let f;
const map = {f = x => x*x => "square"};
let g = map.get(f);
assertEq(g, f);
It's all parseable but an eyesore; but also unlikely/contrived.
const set = {<1, "two", false>};
If you still buy Harmony of My Dreams, prefix # before { to get
immutable value-type forms.
I don't mind reusing => in initialiser context where : would go, but
perhaps someone sees a problem I don't.
Using something other than a colon seems a good idea, to make it clear
that any kind of value can be used as keys.
Another possibility:
```js
const map = {: 1 => "one", "two" => true, false => "three" :};
const set = {. 1, "two", false .};
```
Not sure what's best, but . is visually light, also used in the language
in ways independent from Sets.
I don't see the need for extra delimiters for map literals -- why tax
two chars each literal just for parallelism w.r.t. set literals?
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss