[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reinitialization
- To: Moon@STONY-BROOK.SCRC.Symbolics.COM
- Subject: Re: Reinitialization
- From: Danny Bobrow <Bobrow.pa@Xerox.COM>
- Date: 27 Apr 88 17:03 PDT
- Cc: Common-Lisp-Object-System@SAIL.STANFORD.EDU
- In-reply-to: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>'s message of Tue, 26 Apr 88 16:30 EDT
- Sender: Bobrow.pa@Xerox.COM
check-initargs has to be called from four different places
now, as there are four updating functions that have initargs
arguments. I think the best way is to give check-initargs
another argument, which is a list of generic functions. An
initarg is acceptable if it's a slot-filling initarg or if any
of the generic functions in the list accepts it. make-instance
would pass (list #'allocate-instance #'initialize-instance
#'initialize-new-instance). reinitialize-instance would pass
(list #'reinitialize-instance #'initialize-new-instance). The
only problem with this is that each of these takes
idiosyncratic arguments, which check-initargs has to take into
account when computing the applicable methods. Is there a
better idea?
The basic goal is that for each of the seven functions that
take initargs as arguments (make-instance, allocate-instance,
initialize-new-instance, reinitialize-instance,
update-instance-for-redefined-class,
update-instance-for-different-class, and initialize-instance), the
keyword arguments accepted without error are the initargs for slot
filling and the initargs accepted by applicable methods for any
generic function that is going to see these initargs, and only
those.
The following is an alternative that would be more generally useful. It
provides a more general form of the functionality described above. It will be
useful anytime keyword arguments are going to be combined and passed to multiple
generic functions.
The idea is to have a function that would check a set of keyword arguments
against those accepted by a set of methods. The set of methods would be the
methods from the supplied generic functions that are applicable to the supplied
arguments. In addition, it is possible to specify additional acceptable
keywords.
check-keyword-arguments arguments
generic-functions
&optional extra-allowed-keywords
make instance would call check-keyword-arguments this way
(defmethod make-instance ((class standard-class) &rest initargs)
(setq initargs (default-initargs class initargs))
(unless (check-keyword-arguments
(cons (class-prototype class) initargs)
(list #'allocate-instance
#'initialize-instance
#'initialize-new-instance)
(class-slot-initargs class))
(error "illegal initarg"))
.
.
.)
Clearly the first value returned by this function is T or NIL. There is some
question as to whether it should return other values saying which keyword
arguments were illegal, and what the total set of legal keyword arguments is.