Re: Re: defmethod vs &aux?
JP Massar <[email protected]>
| Newsgroups | gmane.lisp.corman |
|---|---|
| Message-ID | <[email protected]> |
At 12:42 PM 3/11/03 +0100, Frode Vatvedt Fjeld wrote: >Kenny Tilton <[email protected]> writes: > > > (defmethod c-link-ex ((used c-user-notifying) > > &aux (user (car *c-calculators*))) > > ...etc.... > > > > produces this in CormanLisp: > > > > ;;; An error occurred in function COMPILE-FORM: > > ;;; Error: &KEY following &AUX in lambda list: (USED &AUX (USER (CAR > > *C-CALCULATORS*)) &KEY &ALLOW-OTHER-KEYS) > > > > actually, some of my macros have the same bug (if this is a bug), not > > handling &aux. I'll rewrite to work around. fyi. > >I don't know Corman Lisp so well, but I know Closette a bit, and I >suspect the problem is the kludge-arglist function from Closette that >doesn't take &aux into account. Yeah, that's almost certainly the problem. ;;; N.B. The function kludge-arglist is used to pave over the differences ;;; between argument keyword compatibility for regular functions versus ;;; generic functions. (defun kludge-arglist (lambda-list) (if (and (member '&key lambda-list) (not (member '&allow-other-keys lambda-list))) (append lambda-list '(&allow-other-keys)) (if (and (not (member '&rest lambda-list)) (not (member '&key lambda-list))) (append lambda-list '(&key &allow-other-keys)) lambda-list))) the Hyperspec for DEFMETHOD says " The lambda list of the generic function is congruent with the lambda list of the method being defined; if the defmethod form mentions keyword arguments, the lambda list of the generic function will mention ..... key (but no keyword arguments). If function-name names an ordinary function, a macro, or a special operator, an error is signaled." (I didn't put ..... in there; that's what's there. Presumably its a typo and is supposed to read '&key &allow-other-keys'. So the first clause of KLUDGE-ARGLIST makes sense. But I can't find justification for the 2nd IF clause. Section 7.6.4 doesn't seem to justify it. I guess it's just a simplification: Always allow any sort of keywords to appear in any call to a generic function, and not worry about exactly when they are allowed and when they are not. I leave as an exercise for some user of &AUX variables in DEFMETHODS to rewrite KLUDGE-ARGLIST to do the obvious fix. Note that the last sentence of my quote from the HS is violated in Corman Lisp: no error is signalled when a regular function is defined, and then a method by that name is defined. (I'm not sure why the HS insists on an error being signalled; a warning would seem more appropriate.)