The generic function
class-extra-initargs
lets you extend the set of valid initialization arguments for a class and its subclasses.
initargs
should be a list of symbols. Each symbol becomes a valid initarg for the class. By default in a non-delivered LispWorks image, make-instance and other CLOS initializations (see set-clos-initarg-checking) check that initargs passed to them are valid.
The extra initargs are used for make-instance,
reinitialize-instance
, update-instance-for-redefined-class and update-instance-for-different-class.
class-extra-initargs is useful only in complex cases. In most cases other ways of extending the set of valid initargs are simpler and clearer, such as the
:extra-initargs
class option, described in defclass.
In this session an illegal initarg
:my-keyword
is passed, causing
make-instance
to signal an error.
Then
:my-keyword
is added as an extra initarg, after which
make-instance
accepts it.
CL-USER 38 > (defclass my-class () ((a :initform nil)))
#<STANDARD-CLASS MY-CLASS 113AAA2F>
CL-USER 39 > (make-instance 'my-class :my-keyword 8)
Error: MAKE-INSTANCE is called with unknown keyword :MY-KEYWORD among the arguments (MY-CLASS :MY-KEYWORD 8) {no keywords allowed}
1 (continue) Ignore the keyword :MY-KEYWORD
2 (abort) Return to level 0.
3 Return to top loop level 0.
Type :b for backtrace, :c <option number> to proceed, or :? for other options
CL-USER 40 : 1 > :a
CL-USER 41 > (defmethod clos:class-extra-initargs
((x my-class))
'(:my-keyword))
#<STANDARD-METHOD CLOS:CLASS-EXTRA-INITARGS (MY-CLASS) 1137C763>
CL-USER 42 > (make-instance 'my-class :my-keyword 8)
#<MY-CLASS 11368963>
LispWorks User Guide and Reference Manual - 21 Dec 2011