News for hackers. Stuff that matters.
Re:Building a Cache in Elixir by throwawaymaths on Tuesday July 12, 2022 @06:51AM (#32068046)
There is a total order on (almost) all data types in the beam. This is useful for arbitrary sorting and comparison of different types.

I say almost because floats and their equivalent integer are different items but they are equal in the total order. In practice this is fine, and I have never heard of this causing a problem.

Re:Building a Cache in Elixir by a3w on Tuesday July 12, 2022 @07:47AM (#32068484)
For me, no data is either NaN or zero, but +infinity is was the astounding part.

Also, for some languages, not failing with an exception when comparing different strong types, could be a source of bugs, generally.

Re:Building a Cache in Elixir by throwawaymaths on Tuesday July 12, 2022 @09:57AM (#32070016)
In Elixir, nil is an atom (a global enum namespace), it's not a special data type that has meaning outside of a convention (heavily supported by the stdlib) that "you should use it to mean nothing"[0]. To hammer this home, nil is meaningless and not generally understood by that convention in Erlang (which often returns undefined).

Elixir/BEAM is strongly typed. There is no coercion going on when you are doing comparisons.

[0] note that in elixir, "if" is in the stdlib, it's sugar over case, and the falsiness of nil is software-level (only false and nil are falsy in elixir, which is sane).