Using Common Lisp CLOS objects as keys in a hashtable?

前端 未结 1 879
借酒劲吻你
借酒劲吻你 2021-02-14 18:39

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)))

         


        
相关标签:
1条回答
  • 2021-02-14 18:52

    Common Lisp standard does not provide any mechanism to provide additional test functions (beyound standard ones). You have 2 options:

    1. Use genhash genhash which is portable hash-table implementation (not compatible with built-in ones)
    2. Use non-standard extensions:
      1. SBCL has sb-ext:define-hash-table-test function (documentation)
      2. Clisp has a similar function ext:define-hash-table-test (documentation)
      3. Allegro ans Lispworks accept non-standard values for :test argument and has :hash-function argument (Allegro, Lispworks).
    0 讨论(0)
提交回复
热议问题