Brendan Eich (2014-10-02T04:38:09.000Z)
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
forbes at lindesay.co.uk (2016-02-01T12:17:52.047Z)
> Would that be tricky to parse?

The issue would be arrow function expression keys:

```js
const map = {x => x*x => "square"};
```

But such a key could not be found without capturing the reference:

```js
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.

> 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?