[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ensure-generic-function
- To: Gregor.pa@XEROX.COM
- Subject: Re: ensure-generic-function
- From: Patrick H Dussud <DUSSUD%Jenner%ti-csl.csnet@RELAY.CS.NET>
- Date: 12-Feb-87 07:23:50
- Cc: Common-Lisp-Object-System@SAIL.STANFORD.EDU
- In-reply-to: In-Reply-To: Msg of 6-Feb-87 14:14:00 from Gregor.pa@xerox.comMsg of 6-Feb-87 14
- Sender: DUSSUD%Jenner%ti-csl.csnet@RELAY.CS.NET
Date: 6-Feb-87 14:14:00
From: Gregor.pa@xerox.com
Try this for ensure-generic-function:
ensure-generic-function <symbol>
&key (<generic-function-class>
(class-named 'standard-generic-function))
(make-exisiting-function-default-p nil)
If symbol is fboundp to a generic-function of the same class as
<generic-function-class> then this function does nothing
and returns the generic function object.
If symbol is fboundp to a generic-function of some other class, the
generic-function class changing protocol is followed, see chapter3.
If we don't want the type of the generic function to be changed, we can
pass (CLASS-NAMED 'GENERIC-FUNCTION) to the keyword-arg
:GENERIC-FUNCTION-CLASS.
If symbol not foundp a generic function of generic-function-class is
created and put in symbol's function cell.
If this function is meant to be used to normalize the argument to
GET-METHOD then it's not okay to create the generic function. We can
work around it by checking if the symbol is FBOUNDP before calling it
but a situation like this seems to be frequent enough so
ensure-generic-function should handle it.
If symbol is boundp to a function, and make-exisiting-function-default-p
is not nil, a generic-function is created, put in the function cell, a
default method is added to the generic-function and the symbol's
previous function cell value is used as the function for the default
method.
If symbol is fboundp to a function and make-exisiting-function-default-p
is nil an error is signalled.
If symbol names a macro or a special form, an error is signalled.
OK.