(defgeneric eqv (a b)
(:documentation "This method is used to compare classes. Override it
to specialize it's testing for your classes. There's already a method
specialized for built in classes that uses EQUAL, cons cells, and any
standard object."))
(defmethod eqv (a b)
(equal a b))
(defmethod eqv ((a cons) (b cons))
(cond
((and a b)
(and (eqv (first a) (first b))
(eqv (rest a) (rest b))))
(t
nil)))
(defun and-list (list)
(if list
(and (first list)
(and-list (rest list)))
t))
(defmethod eqv ((a standard-object) (b standard-object))
(when (eq (type-of a) (type-of b))
(and-list
(mapcar #'(lambda (slot)
(eqv (slot-value a slot)
(slot-value b slot)))
(mopu:slot-names (find-class (type-of a)))))))