In article <··············@mute.eaglets.com>, Sam Steingold <···@usa.net> wrote:
> The following signals an error:
>
> (defgeneric zz (&rest args)
> (:method ((x real) (y real) &optional (stream t))
> (format stream "~a" (+ x y)))
> (:method ((z t) &optional (stream t)) (format t "~a" z)))
>
> *** - #<standard-method (#<built-in-class real> #<built-in-class real>)>
> has 2, but #<generic-function zz> has 0 required parameters
>
> I hope it's clear what I want. Is there a *good* way to do this in CL?
> (I don't want to check for the type of the first arg myself etc).
>
> Thanks.
>
Something like this would work (writing some documentation would help):
(defgeneric zz (arg &rest args)
(:method ((x real) &rest args)
(format (second args) "~a" (+ x (first args))))
(:method (z &rest args)
(format (first args) "~a" z))
(:documentation "Your Doc here."))
(zz 3 4 t)
(zz 'a t)
--
http://www.lavielle.com/~joswig/