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

symbols are not generic functions

    Date: 26 Jan 87 14:12 PST
    From: Gregor.pa@Xerox.COM

    symbols are not generic functions, they can only be used to name a
    generic function.  The primitive levels of the meta-interpreter deal
    with generic-function objects.  symbols as names of generic functions
    are a convenience provided by defmethod, defmethod-setf
    defgeneric-options etc.

    Consequently, I would like to propose the following change.

    I suggest that add-method, remove-method and get-method be changed to
    require that their first argument be a generic-function object.  Along
    with this I would like to introduce a new function which will provide
    the functionality I am proposing we remove in a more rational way.

This change is okay with me.  See comments below.

    ensure-generic-function (or some such name) takes a symbol, or a list
    (SETF <symbol>) and makes sure there is a generic function of the
    default kind (standard-generic-function) "there".  For convenience,
    ensure-generic-function returns that generic function.

I don't completely understand.  Suppose symbol-function of the symbol
is already a generic function, but it is of a different class than the
kind that you get by default, because someone is using generic-function
meta-objects.  Would ensure-generic-function accept that generic
function, signal an error, or clobber it with a generic function of
the default kind?

Also, does ensure-generic-function ever alter the symbol-function of
a symbol, or is it just a side-effect free coercion?  If the latter,
it might be cleaner to use the existing COERCE function, thus
(add-method (coerce <arg> 'generic-function) <method>).

    This means that (in some of the cases) where you used to write:

       (add-method 'foo <method>)

    you will write

      (add-method (ensure-generic-function 'foo) <method>)

    There is no doubt that this is more verbose in the cases where you have
    to use ensure-generic-function, but I believe it is much clearer.