[erlang-questions] Trouble with Erlang's lenient comparisons
Thu Apr 14 16:23:02 CEST 2011
----- "Richard O'Keefe" <ok@REDACTED> wrote:
> On 14/04/2011, at 3:52 AM, Robert Virding wrote:
> > The comparison operators as they are now were a mistake, almost a
> bad mistake. IMAO what we should have done was to have had two
> different sets of operators, one set of numeric comparisons (without
> type conversion) and one set of gerneral term comparisons (without
> type conversion). So for example:
> > == /= =< < >= > would only work on numbers
> > @== @/= @=< @< @>= @> would work on all terms
> Just like Erlang's predecessor Prolog!
> Since the term/number distinction _was_ borrowed for equality and
> inequality (although with the symbols switched around, which still
> confuses me), I've often wondered why it wasn't borrowed for ordering.
Yes, my suggestion is taken directly from the Prolog operator names. I don't have a problem with that. :-)
Originally there was no problem as we did not have floating point numbers. It was only when they were added and we decided to do implicit type conversions that the problem arose. We needed an exact equality check for pattern matching so =:= was added (yes it was a bad name choice) and =/= just tagged along and slipped in.
I suppose I will have to make an eep which suggests the complete range of term comparison operators without type conversions. The problem is whether it is worth effort to add pure numeric comparisons as well.
More information about the erlang-questions