Next Prev Up Top Contents Index

class-extra-initargs

Generic Function
Summary

Extends the valid initialization arguments of a class.

Package

clos

Signature

class-extra-initargs append 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. Note that by default make-instance checks that initargs passed to it are valid.

The method combination of class-extra-initargs is append , so extra initargs from all the applicable methods are appended.

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
	                append ((x my-class))
               '(:my-keyword))
#<STANDARD-METHOD CLOS:CLASS-EXTRA-INITARGS (APPEND) (MY-CLASS) 1137C763>
 
CL-USER 42 > (make-instance 'my-class :my-keyword 8)
#<MY-CLASS 11368963>
See also

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


LispWorks Reference Manual - 13 Jun 2003

Next Prev Up Top Contents Index