[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Check-keyword-arguments



Here is another approach. I believe we need to have a procedural
definition of make-instance (and maybe other initialization-like
functions), and we need for them to be models for users to imitate.
Therefore, the error situation must be handled correctly in make-instance.
Because check-keyword-arguments is pretty ugly already, why not simply
make it do what it needs to do (and maybe some useful but not required
things too)?

So here's the new specification for check-keyword-arguments:

check-keyword-arguments keywords-or-keyword-plistp
		        keywords-or-keyword-plisp
		        generic-functions-and-arguments-or-methods
		        extra-allowed-keywords
		        &optional errorp-or-function

keywords-or-keyword-plistp:

I don't think we need to restrict this function to a plist of keywords and
values, as in an initarg list. A list of keywords is a useful argument
too.  So the first argument tells which to expect as the second argument.
(I don't think this wrinkle is necessary, so we could drop it.)

keywords-or-keyword-plisp:

Either a list of keywords or a plist of keywords and values.

generic-functions-and-arguments-or-methods:

A list of elements, each of which is either a method or a pair. If an
element is a pair, the car is a generic function and the cdr is a set of
required arguments that are used to select a set of applicable methods. If
the cdr of the pair is nil, all methods for that generic function are
used.

extra-allowed-keywords:

This is a list of additional keywords to consider as legal.

errorp-or-function:

This is an optional argument that defaults to nil. If it is nil, then
check-keyword-arguments returns T if all is well or the list of losing
keywords if some fail to be ok. If it is non-nil, an error will be
signaled. When the error is signaled, the message is constructed from the
value of errorp-or-function. If it is a string, it is taken as a format
string to be included in the message. If it is a symbol, it is taken as
the name of the function in which check-keyword-arguments is being called
and is used in the error message. If it is a function (or generic
function), it is the function in which check-keyword-arguments is being
called and is used in the error message.

I also thought of providing a predicate to test keywords, but this
could be handled outside of check-keyword-arguments.

This is pretty gross, but I think we are concentrating all of the ugliness
in one place, which is better than either spreading it around or
presenting an incomplete procedural definition of make-instance.

			-rpg-