I thought i could define a method which accepts keyword arguments. But when i have multiple methods with keyword arguments of different types, it seems that lisp uses the last evaluated method. For example below:
(defmethod f (&key (x list)) (make-list 3 :initial-element (first x)))
(defmethod f (&key (x number)) (* 2 x))
Now f
's :x
accepts only numbers and throws errors for lists:
(f :x 2) ;4
but
(f :x '(2))
The value (2) is not of type NUMBER when binding SB-KERNEL::X [Condition of type TYPE-ERROR]
How can i define multiple methods with &key args of different types?