[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what most every language is missing :-)



> How about adding a "might-equal" operator?

This joke immediately reminded me of ``The Best of Intentions: EQUAL
Rights--and Wrongs--in Lisp'' by Kent Pitman (available on the web at
http://www.nhplace.com/kent/PS/EQUAL.html). Kent makes the point that,
in providing ``copy object'' and equality-testing functions, language
designers often make rather arbitrary decisions, and, in the general
case, what the application programmer means by ``equality'' often does
not map well onto any given language's standard equality tests.

Here are some relevant quotes; I highly recommend reading the whole
paper.

    ``There is no uniquely determined equality function for complex
    structures--there are only arbitrary ones.

    ``EQUAL and EQUALP are just two of an arbitrary number of possible
    equality operations that could have been provided by the language.
    Indeed, many of the dialects which contributed to the design of
    Common Lisp had functions called EQUAL which had slightly varying
    semantics. No particular definition was definitively better than
    another. Arbitrary choices were made to resolve the differences.

    [...]

    ``The orderliness of this relationship [between EQ, EQL, EQUAL, and
    EQUALP] contributes to a mistaken impression among some programmers
    that the equality testing done by EQUAL and EQUALP is somehow more
    special than many similar predicates we could have provided but did
    not. This is evidenced in occasional bug reports that vendors
    receive, arguing that an incorrect choice has ``clearly'' been made
    for how objects of a given type are compared, rather than
    acknowledging that the choice is really quite arbitrary. When urged
    to write their own equality predicate to suit their particular
    needs, they sometimes react as if we are putting them off, rather
    than realizing that any function they could write is just as valid
    as any one the language provides. [...] EQUAL and EQUALP are not in
    Common Lisp because they are uniquely dictated by science[...]''


Ted

-- 
Edward O'Connor
ted@oconnor.cx

Ense petit placidam sub libertate quietem.