CLOS: How to make a slot have an enforced type of vector of symbols?

后端 未结 2 2032
轮回少年
轮回少年 2021-01-19 01:53

I\'m trying to create a class that can store a vector of symbols in a slot in SBCL. I cannot figure out how to set it up.

My best guess thus far has been

         


        
相关标签:
2条回答
  • 2021-01-19 01:55

    I know I'm probably too late, but you should wrap around your classe declaration with a optimization for safety. For example:

    (locally (declare (optimize safety))
        (defclass test-class ()
          ((some-slot :type real :initarg :some-slot :accessor :test-some-slot))))
    
    0 讨论(0)
  • 2021-01-19 02:03

    You might consider defining an :after method on slot accessor/writer. Also, the ultimate degree of control can be exercised by defining your own metaclass and customization of slot-value-using-class

    0 讨论(0)
提交回复
热议问题