For a mutable reference type, I strongly recommend that you distinguish instances by identity rather
than by content. If it’s a structure type — defined by defstruct — I recommend adding an
explicit id slot and supplying that to define-equality-slots. For convenience in
doing this, FSet exports define-atomic-series and increment-atomic-series. Here’s an
example of their use:
(define-atomic-series next-frob-id) (defstruct (frob (:constructor make-frob (size color location &aux (id (increment-atomic-series next-frob-id))))) id size color location) (define-equality-slots frob #'frob-id)
Every time make-frob is called, the id of the result will be initialized to the next
integer in the series.
If your mutable reference type is a standard class — defined by defclass — it’s even
easier: just include identity-equality-mixin as a superclass; FSet handles the rest.