[erlang-questions] Accessing a single value from MAPS

zxq9 <>
Fri Oct 9 01:18:50 CEST 2015


All that inconsistency in the language SO PEOPLE CAN USE GODDAM DOTS?!?!?


OK. That's out of my system.

Seriously, what is this obsession with dots? It amazes me that this sort of thing comes up so often, is demonstrated to be a bad idea, and then comes up again weeks later. Thoughtlessly adding syntactic sugar without a reason better than "braces and hashes and whatnot are considered ugly by (my) current fashion standards" is how you wind up with an unrecoverable stew of profoundly weird and unrecoverably ugly syntax and semantics. Consider Ruby. Or C++. Compare that to Python, where adding a syntactic convenience usually requires something close to a multi-year civil war. The difference in outcome is clear.

I would much prefer that Erlang continued to err on the side of being too slow to depart from its Prologish syntax roots and remain consistent and unsurprising, regardless the prevailing syntax fads of this or that decade. In fact, I would prefer if most of the code I see continues uses maps:get/2,3 and wouldn't be bothered at all if there had never been any specific hash-and-braces-sometimes-with-arrows syntax for maps.

The syntax of maps is utterly uninteresting -- the underlying data structure is the useful part.


On 2015年10月8日 木曜日 17:55:07 Tony Rogvall wrote:
> Why not only support atom keys for the dot notation and let more complex keys use maps:get???
> That would cover most of my uses of maps ( but far from all )
> /Tony
> > On 8 okt. 2015, at 16:47, Fred Hebert <> wrote:
> > 
> >> On 10/08, Fred Hebert wrote:
> >> Map.f.'d.e'.#{=>ok} to go fetch the final 'ok'. Either that or you·
> >> support little chaining, but there's still plenty of ways to make this·
> >> terrible.
> > 
> > Oh also, if any form of chaining is required, it is now impossible to know if Map.3.5 is supposed to be Map.(3.5) or two maps, one with the key 3 and the key 5. I guess parentheses could make it work. But even with records this was kind of messy.

More information about the erlang-questions mailing list