:method
:method-combination
:argument-precedence-order
(defgeneric Area (Geometric-Object) (:documentation "Area of geometric object in square meters"))
(defgeneric Area (Geometric-Object) (:documentation "Area of geometric object in square meters") (:method ((C Circle)) (* pi (expt (Radius C) 2))) (:method ((R Rectangle)) (* (Width R) (Height R))) ...)
Some options:
The default.STANDARD
Execute all methods that apply in most-specific to least-specific order.PROGN
(defgeneric Print-Identity (Obj) (:method-combination progn)) (defmethod Print-IdentityOther options includeprogn ((R Rectangle)) (print "I'm a Rectangle") R) (defmethod Print-Identityprogn ((S Square)) (print "I'm a Square") S) (Print-Identity Square-1) "I'm a Square" "I'm a Rectangle" ==> #<Square-1>
+, list, and, or, max, min, append and nconc.
(defmethod Foo (Item (L list)) (Frobify Item L)) (defmethod Foo ((L list) Item) (Munge Item L))Now consider a call to
Foo with two lists: (Foo '(A B C) '(D E F)). The second version of Foo will get invoked, since it has the more specific match on the first argument, and the arguments will get munged instead of frobified. However, if you had first done:
(defgeneric Foo (Item1 Item2) (:documentation "Foo takes 2 entries and Munges or Frobifies them") (:argument-precedence-order Item2 Item1))
then (Foo '(A B C) '(D E F)) would have gotten the first version, since it is has a more specific match on Item2, which is listed first in the :argument-precedence-order entry.