I am trying to do an βebull overload callβ in Common Lisp. Here is a simplified summary of the case:
(defclass foo ()
((slotty :accessor slotty :initarg :slotty)))
(defclass bar ()
((slotty :accessor slotty :initarg :slotty)))
(defparameter *foo* (make-instance 'foo :slotty "defnoodle"))
(defparameter *bar* (make-instance 'bar :slotty "Chocolate"))
(defmethod contrived ((f foo) (b bar))
(format t "i pity the foo ~A, who has a bar ~A ~%" (slotty f) (slotty b)))
(contrived *foo* *bar*)
outputs: i pity the foo defnoodle, who has a bar Chocolate
But as soon as I try to define the following method:
(defmethod contrived ((f foo))
(format t "i just pity the foo ~A ~%" (slotty f)))
CL is angry:
Does anyone know what I'm doing wrong here? I know that initialize-instance has similar flexibility, because you need to be able to identify the n number of initialize-instance methods for each class and for any number of arguments.
(defmethod initialize-instance :after ((f foo) &key)
())
but I donβt understand how I can translate this into the example of vanilla, which I gave above. And I feel that I can bark the wrong tree, as it is part of the SS.
source
share