Es6_maps - EcmaScript6-style shorthand map literals

I’d personally be very happy with a solution like that built into the language.

Assuming you’re talking about es6_maps:

The pin operator support is something I’d like to see in the library in the future – the bigest impediment being that %{^x, y: 1} is not valid syntax and doesn’t make it to the AST stage, unlike %{x, y: 1}.

Map & struct updates are supported and there’s a couple examples in the README.

From my PoV the problem is, it’s really tricky to implement this as a library in a way that feels like a natural part of the language.

I was fine with requiring use Es6Maps in each module that wanted shorthands, but between @on_definition deliberately not calling macros, @before_compile actually happening after a compilation pass, and this post from @josevalim, there weren’t many options left aside from modifying the compiler in-flight to get this. It would be great to be able to create language extension PoCs that could make it into the standard implementation.

Already added, there’s an Es6Maps.Formatter included in the library. You add it as plugins: [Es6Maps.Formatter] to .formatters.exs, call mix format, and all of your maps will be converted.

Unless you mean something like “display shorthand maps in the editor, save normal maps to disk”? That sounds like an interesting feature for ElixirLS.

1 Like