<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 10/27/2017 04:39 PM, Richard
Carlsson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CANKG3znZd4i9KaD3Abb03fDS2am1HghzboWrN6gp0vVPqK=GNQ@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr">
<div class="gmail_extra">
<div>
<div class="gmail_signature"
data-smartmail="gmail_signature">2017-10-27 15:26
GMT+02:00 Sverker Eriksson <span dir="ltr"><<a
href="mailto:sverker.eriksson@ericsson.com"
target="_blank" moz-do-not-send="true">sverker.eriksson@ericsson.com</a>></span>:<br>
</div>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p>Yes. All Erlang terms, including maps, have a
globally defined, implementation independent, total
order.<br>
</p>
The reason, for this "surprising" order of maps, is the
alternative of using the normal arithmetic order for
keys is much worse.<br>
<br>
If we want 1 and 1.0 to be different keys (which we do
as we use matching (=:=) to lookup keys)<br>
then we need to order 1 and 1.0, and normal arithmetic
term ordering does not (1 == 1.0).<br>
</div>
</blockquote>
<div><br>
</div>
<div>Yes... but I'm not sure that the term order when
comparing one map to another needs to have anything to do
with how lookup works within maps (much like it doesn't in
an orddict, gb_trees, or similar). The global term order
only needs to be fixed and preferably straightforward. I
could, for example, implement maps using the sort of tuple
I showed: {K1, ..., Kn, V1, ..., Vn}, and they would have
one order given by '>', but using #{K1=>V1, ...
Kn=>Vn}, they would be ordered differently if keys were
floats. I think that key order as used internally by the
maps could and should be kept separate from the global
term order.</div>
<br>
</div>
</div>
</div>
</blockquote>
<br>
orddict and gb_trees both use '==' to distinguish keys, which makes
it possible to order them with '>'.<br>
<br>
How would you orderĀ #{1 => x, 1.0 => y} and #{1 => y, 1.0
=> x}<br>
if you can't order 1 and 1.0?<br>
<br>
<br>
<br>
/Sverker<br>
<br>
</body>
</html>