NextPrevUpTopContentsIndex

class-extra-initargs

Generic Function
Summary

Extends the valid initialization arguments of a class.

Package

clos

Signature

class-extra-initargs prototype => initargs

Arguments

prototype

A class prototype.

Values

initargs

A list of additional initialization arguments.

Description

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 checks that initargs passed to it are valid.

Note: 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.

Example

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>
See also

compute-class-potential-initargs
defclass
make-instance
set-make-instance-argument-checking


LispWorks Reference Manual - 23 Jul 2004

NextPrevUpTopContentsIndex