Map literal
Francisco Tolmasky
tolmasky at gmail.com
Sun Nov 29 21:41:01 UTC 2015
My one desire (perhaps not completely substantiated) would be that the
“list” portion of the syntax exist outside of these expressions as well.
That is to say, if:
```
new Dict#{a: b, c: d }
```
desugars to:
```
new Dict([[a,b], [c,d]])
```
Then I’d like/expect #{a: b, c: d} to also just desugar to [[a,b], [c,d]].
More than anything, I would just expect this to be the case if I ran into
it in the wild. As such, perhaps one way to look at this is that what we
actually want is a nice tuple syntax. Imagine if we had just a tuple syntax
taht a->b desugars to [a,b]. Now, with no further changes, we get this “map
syntax” for free:
```
new Map([a->b, (4+5)->d, null->7])
```
That looks pretty good to me, and introduces a new operator that behaves
the same everywhere, and has minimal requirements to “new” collection
classes. Additionally, I would enjoy returning these as well when referring
to key value pairs:
```
return (a->b) // sugar for return [a,b]
```
--
Francisco Tolmasky
www.tolmasky.com
tolmasky at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151129/aae3edbe/attachment.html>
More information about the es-discuss
mailing list