[erlang-questions] Maps

Fred Hebert mononcqc@REDACTED
Wed May 8 17:39:56 CEST 2013

I was looking at an example:

    1> M = #{ 1 => a },
    #{ 1 => a }
    2> M#{ 1.0 => b }.
    #{ 1.0 => b }.
    3> M#{ 1 := b }.
    #{ 1 => b }
    4> M#{ 1.0 := b }.
    ** exception error: bad argument

And given the definition where we have 'match' and 'equal' being two
different things, am I right in understanding that '=>' can both create
a mapping and update it based on 'equal' whereas ':=' can only update
them using 'match' ?

That seems like tricky semantics to me. Any reason why one can both
update and insert but not the other? It's not like one operator is the
alternative of the other exclusively on update/create or match/equal,
but they're different in both forms.

For the Dialyzer syntax, is there any distinction for types that have to
do with empty/non_empty maps?

I don't think there is any mention of the expected behaviour when
matching on #{_ := V} = #{a => 3}, unless I missed it (there
were cases in map comprehensions, but these are obviously not the same).
Does this need to be specified? Similarly, #{_ := V} = #{a => 1, b => 1}
and #{K := 1} = #{a => 1, b => 1} do not seem specified to me.

For the rest of it, that looks like a decent proposal, and I'm
interested by map comprehensions, but I'll let guys like ROK or jlouis
take a more critical look at it ;)

I'm just hoping nobody's gonna end up using maps as the thing that all
state of all apps of all processes use and send over messages and you
just have to look inside the map, son, because I'm not gonna go through
the bother of sending concise messages to you!


More information about the erlang-questions mailing list