Hello!
I am writing a program in LISP, using CLOS. I designed
two independent classes, both with a method called 'add'.
The problem is, the argument list of the two add methods
is different, which is not allowed in CLOS.
Example:
USER(1): (defclass a () ())
#<STANDARD-CLASS A>
USER(2): (defmethod add ((self a) x) (format nil "class a"))
#<STANDARD-METHOD ADD (A T)>
USER(3): (defclass b () ())
#<STANDARD-CLASS B>
USER(4): (defmethod add ((self b) x y) (format nil "class b"))
Error: Attempt to add the method
#<STANDARD-METHOD ADD (B T T) @ #x44c45aa> to the generic
function #<STANDARD-GENERIC-FUNCTION ADD> but the method has
more required arguments than the generic function.
[condition type: PROGRAM-ERROR]
Of course a solution could be to give the methods different
names, but I think that is unsatisfactory.
Do you have any ideas of how to get around this? I intend
my program to be platform independent.
Regards,
David Kaasen.