The metaclass of the class being parsed.
The defclass option name.
The tail of the defclass option form.
The generic function process-a-class-option
describes how the value of a class option is parsed. It is called at defclass macroexpansion time. By default LispWorks parses class options as defined in AMOP, but you need to supply a method if you need class options with different behavior.
initargs should be a plist of class initargs and values. These are added to any other initargs for the class.
(defclass m1 (standard-class)
((title :initarg :title)))
For single-valued, evaluated title option, add a method like this:
(defmethod clos:process-a-class-option
((class m1)
(name (eql :title))
value)
(unless (and value (null (cdr value)))
(error "m1 :title must have a single value."))
(list name (car value)))
(defclass my-titled-class ()
()
(:metaclass m1)
(:title "Initial Title"))
If the value is not to be evaluated, the method would look like this:
(defmethod clos:process-a-class-option
((class m1)
(name (eql :title))
value)
(unless (and value (null (cdr value)))
(error "m1 :title must have a single value."))
`(,name ',value))
Now suppose we want an option whose value is a list of titles:
(defclass m2 (standard-class)
((titles-list :initarg :list-of-possible-titles)))
If the titles are to be evaluated, add a method like this:
(defmethod clos:process-a-class-option
((class m2)
(name (eql :list-of-possible-titles))
value)
(list name `(list ,@value)))
Or, if the titles should not be evaluated, add a method like this:
(defmethod clos:process-a-class-option
((class m2)
(name (eql :list-of-possible-titles))
value)
(list name `',value))
(defclass my-multi-titled-class ()
()
(:metaclass m2)
(:list-of-possible-titles
"Initial Title 1"
"Initial Title 2"))
LispWorks User Guide and Reference Manual - 13 Feb 2015