In Logic there is one and only one unambiguously(*) defined notion of equality: two things are equal if and only if they are the same thing.
Programming languages of course try to emulate this concept but unfortunately the limitations imposed by the finitary nature of computers do not allow for a true notion of equality. In Lisp (I should actually restrict myself to e-lisp which I have made some effort in learning) there are lots of alternatives to choose from, such as equal
, eql
, eq
, =
, string-equal
, char-equal
and the list does not stop here.
It seems to me that this is a bit of an overkill solution, since it could be replaced by a single notion of equality, which in turn could be combined with the various available predicates, such as type-of
, to achieve the effects of the various ideas of equality. By the way, it would be nice to also have a predicate telling the memory address where a variable resides (which I suppose is behind the idea of eq
).
This solution works very nicely in other programming languages such as Pascal, where you can compare x=y
(same contents) or @x=@y
(same addresses). It is true that Pascal is a lot more rigid than Lisp regarding variable types, but you can still compare say, integers and reals, with correct answers.
My question it thus, what is the justification for so many notions of equality in e-lisp?
(*) Lastly let me make a small disclaimer regarding my above statement about the nature of equality in Logic: we all know that rational numbers are defined as equivalent classes of pairs of integer numbers, so the rational number 1 is not technically equal to the integer number 1. Thus it could be argued that the difficult dilemma about the meaning of equality is also present in Logic.