[erlang-questions] Maps branch and disclaimers

Fred Hebert <>
Fri Oct 25 20:15:44 CEST 2013

On 10/25, Björn-Egil Dahlberg wrote:
> Roughly,
> M0 = #{ key => Value1, "key" => Value2}, % for construction.
>   M1 = M1#{  "key" := Value3, <<"key">> => Value4 }, % for updates
>   #{ "key" := V } = M1. % for matching

I assume you meant M2 = M1#... here?

> ...
> _The External Format_
> The current external format /needs/ ordered keys as input for
> binary_to_term/1 and in distribution.
> This is of course an inconvinience when dealing with other language
> interfaces which has no idea of what the erlang term order is. I
> instead propose that the external format should handle unordered
> input of key-value pairs. The trade off is a more complicated
> decoding which will take longer.

Could there be a flag in there that will allow to specify whether the
terms are ordered or not? It sounds to me like this could yield the
lowest cost for languages that *do* support sorting in manners similar
to Erlang (most notably, other Erlang nodes), while having very little
overhead for talking with other languages (where most of the time will
be spent unserializing anyway).

The flag could be ignored by languages unserializing the terms that do
not understand/need Erlang's ordering, too, or optimize accordingly.

> The distribution format should also be extended to be able cache
> keys. This is similar to the atom cache except we
> cache the entire key array for maps. This has been the intention all
> along but it not mentioned in the EEP.

Shall the EEP be extended?

> _Term order and sorting_
> The Erlang term order is what I call arithmetic term order. I
> propose that we extend Erlang with true term order where integer
> compares less then float, i.e. total term order.
> ...
> But for completness, the following operators should also be implemented:
>     =:=         term exact equal to, already implemented
>     =/=         term not equal to, already implemented
>     =:<         term less or equal than
>     >:=         term greater or equal than
>     <:<         term less than
>     >:>         term greater than

Hell yes! I've found this extremely annoying for a long while. I could
see the use of this, and it could be done without breaking backwards
compatibility, except in some rare cases where it could be perceived as
somewhat inconsistent (orddicts come to mind, where they use the
arithmetic term order internally, but still enforce the true term order
for keys -- and I can't see this being fixed)

For what it's worth, Prolog's operators are @<, @=<, @>, @>=. I think
that I would prefer your form, but someone with more clout on the matter
(such as ROK) would be better placed than me to voice an opinion on


More information about the erlang-questions mailing list