[erlang-questions] strictly less-than (Re: [erlang-questions] Ordered set and DETS)

Ulf Wiger ulf.wiger@REDACTED
Mon Sep 6 17:30:02 CEST 2010

On 09/06/2010 05:03 PM, Nicholas Frechette wrote:
> Is that not the expected behavior per the erlang doc?
> http://www.erlang.org/doc/reference_manual/expressions.html

Well, yes, but that in itself is no guarantee that it is a
good solution. ;-)

> Incidentaly, what would you expect of the following:
> 1 < {foo, 2}
> 1 > {foo, 2}
> 1 == {foo, 2}
> 1 =:= {foo, 2}

There is nothing strange or unambiguous there.
Erlang has a global term comparison order so e.g. 1 < {foo,2} is
perfectly well defined.

The int->float coercion is fine... until it's not. That's why
we have =:= and =/=, because in some cases, 1 and 1.0 really
are distinctly different.

I have managed to get by programming erlang for the better part of
17 years before I was finaly bitten by this, so I'm perfectly willing
to go on happily without ever seeing this corrected.

However, I really don't see the disadvantage of ensuring that the
global comparison order can be guaranteed across the board, without
any surprising corner cases, and I think lists:sort/1 et al should
really be able to provide such guarantees.

BTW, there was another interesting edge case some years ago, that
proved very troublesome for mnesia. Pids did not sort the same
way on all connected nodes in a distributed erlang network. This broke
some fundamental assumptions in mnesia's deadlock detection algorithm.
It has long-since been fixed, but having a truly universal sort order
really is a very good thing.

Ulf W

More information about the erlang-questions mailing list