Using Common Lisp CLOS objects as keys in a hashtable?

Viewed 983

I'd like to use Common Lisp CLOS objects as keys in a hashtable. I thought it would be as simple as this:

(defclass my-class () ((a :accessor a :initarg a)))

(defun my-class= (my-instance-1 my-instance-2)
(equal (a my-instance-1) (a my-instance-2)))

(defparameter my-hash-table (make-hash-table :test #'my-class=))

Checking out the Common Lisp Hyperspec, it seems I can only use eq, eql, equal, or equalp to test equality.

Is there any way I can do this? Or is this just a really stoopid thing to do, and that's why the standard doesn't allow it?

1 Answers
Related