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

Re: symbols are not generic functions



in reference to ensure-generic-function, Moon says:

    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?

Well, the short lazy answer is ensure-generic-function does whatever
add-method was going to do.

The long answer is we need to figure this out.

1. perhaps ensure-generic-function should take a second argument which
would be the class of the generic function to make if there isn't one.

2. There is a part of the meta-object protocol which deals with whether
or not is is permissible to change the class of a generic function, that
part of the protocol should be called here when there is already a
generic function but its the wrong class.

3. Perhaps ensure-generic-function should take another argument which
could be used to specify that if there is a function in the place, but
its not a generic-function, it should become the default method for the
new generic function.

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

I am not sure about this given what I said above.