我想使用 Common Lisp CLOS 对象作为哈希表中的键。我认为它会像这样简单:
(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=))
查看 Common Lisp Hyperspec,似乎我只能使用 eq、eql、equal 或 equalp 来测试相等性。
有什么办法可以做到这一点吗?或者这只是一件非常愚蠢的事情,这就是为什么标准不允许这样做?