Macro Compare-Slots
(
compare-slots obj1
obj2
&rest
accessors
)
A handy macro for writing the bodies of compare
methods for user classes.
Returns the result of comparing the two objects by comparing the results of
calling each of accessors
, in order, on the objects. Despite the name, an
accessor can actually be any function on the class in question; it can also
be a symbol, which will be used to access the slot via slot-value
. For
example, if class frob
has accessor frob-foo
and slot bar
:
(defmethod compare ((f1 frob) (f2 frob))
(compare-slots f1 f2 #'frob-foo 'bar))