[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I change the arguments of a generic function?
- To: firstname.lastname@example.org (UEDA masaya)
- Subject: Re: How can I change the arguments of a generic function?
- From: email@example.com (Bill St. Clair)
- Date: Thu, 22 Oct 1992 10:20:19 -0500
- Cc: info-mcl
>Yes I can. But if I type Command-/ to continue, existing methods are
>removed. When I wrote those methods, I do not hesitate. But when they
>are predefined methods, what should I do?
>For example, if I define an :after method of set-view-font-code and try
>to add a new keyword argument to it, Error: Incompatible lambda list
>? (defmethod set-view-font-codes :after ((kfm kanji-fred-mixin) ff ms
> &optional ff-mask ms-mask
> &key foo)
>> Error: Incompatible lambda list in #<STANDARD-METHOD SET-VIEW-FONT-CODES :AFTER (KANJI-FRED-MIXIN T T)> for #<STANDARD-GENERIC-FUNCTION SET-VIEW-FONT-CODES #x94A576>
>> While executing: CCL::CHECK-DEFMETHOD-CONGRUENCY
>> Type Command-/ to continue, Command-. to abort.
>> If continued: Remove 5 methods from the generic-function and change its lambda list.
>See the RestartsI menu item for further choices.
>If I type command-/, 5 set-view-font-codes methods are removed and the
>result is not acceptable.
>Is such attempt pseudo in itself?
>Any suggestion would be appreciated.
MCL tries to do what it can when you change the lambda list of a
generic function. For now, that means removing all the old methods
whose lambda lists are not congruent. I can envision a little more
DWIMish functionality that would realize that all you did was add
some keyword args that could be ignored by the existing methods, but
implementing this would take a lot of work. In my opinion, what you are
doing is not redefining set-view-font-codes. You are defining a new generic
function with added functionality:
(defmethod kanji-set-view-font-codes (view ff ms &optional ff-mask ms-mask)
(set-view-font-codes view ff ms ff-mask ms-mask))
(defmethod kanji-set-view-font-codes :after ((kfm kanji-fred-mixin) ff ms
&optional ff-mask ms-mask
Now all of your new code can call kanji-set-view-font-codes instead
Aside: Note that this new generic function is going to be
subject to the same confusion as the Common Lisp read-from-string function:
it has optional and keyword arguments. People will write:
(kanji-set-view-font-codes view ff ms :foo foo-value)
when they really need to write:
(kanji-set-view-font-codes view ff ms nil nil :foo foo-value)
Possibly kanji-set-view-font-codes doesn't need to support the ff-mask and