As mentioned previously, compare allows you to use
instances of different classes as elements of a set or bag, or keys of a map. Instances of
different classes are compared by class first. There are two ways this comparison can be
performed:
compare that match each pair of types and return a predetermined value, either :less
or :greater.
If you know you are going to be making a lot of mixed-type collections, and some of the types involved are user-defined, you can use the following macro to make comparing them faster:
Generates cross-type methods on compare for the specified class, against all classes on which
this has previously been done. FSet invokes this on the supported CL types and most of its own types.
This macro is intended to be invoked at the top level of a source file. You should make sure that calls to this macro are always compiled in the same order; if you don’t, you could possibly get a “master type ordering out of sync” error, at which point you should delete all your fasls, restart your Lisp session, and recompile.