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

symbols are not generic functions



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.

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.

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.