CLOS: How do slots have a forced character vector type?

I am trying to create a class that can store a character vector in a slot in SBCL. I can’t figure out how to configure it.

My best guess so far has been

(defclass Individual () ((discrete-decisions :type (vector symbol)))) 

This returns the following error:

 keyword argument not a symbol: (DISCRETE-DECISIONS :TYPE (VECTOR SYMBOL)). [Condition of type SB-INT:SIMPLE-PROGRAM-ERROR] 

Some experiments have shown that changing the type of only symbol returns the same error. I thought symbol is a valid type in Common Lisp ... am I mistaken?

How can I make this work?

[EDIT]

I had a problem with SBCL 1.0.58 in the Slime build 09-22-2012 under Emacs 24.2. When I run SBCL 1.0.58 from the command line, there is no problem. This is not like a SBCL problem ...

+4
source share
2 answers

You might want to define an after method after using the accessor / writer slot. In addition, the maximum degree of control can be realized by defining your own metaclass and setting the slot-value usage class.

+3
source

I know that it's probably too late, but you should wrap your class declaration as an optimization for security. For instance:

 (locally (declare (optimize safety)) (defclass test-class () ((some-slot :type real :initarg :some-slot :accessor :test-some-slot)))) 
+2
source

Source: https://habr.com/ru/post/1435806/


All Articles