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

Re: ensure-generic-function

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