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

Re: EQUAL isn't really correct, I agree



The problem of wanting to handle EQUALity differently for different
objects can be naturally handled by defining (a version of) EQUAL as a
*method*, which can be specialized for whatever types the user has in
mind. 

E.g.,

(defmethod equal (x y) (eq x y))
(defmethod equal ((x cons) (y cons))
   (and (equal (car x) (car y))
        (equal (cdr x) (cdr y)))


(defmethod equal ((x flonum) (y flonum)) (= x y))


etc.

I'd add EQUAL to the list of built-in Common Lisp functions for which
allowing specialization is a Good Thing.