对象与多分派

ZOS:defclass 描述对象,泛型函数按参数类型选择方法。

ZOS:类描述对象,泛型函数按参数类型选择方法。

(defclass point () ((x :initarg :x) (y :initarg :y)))
(def p (make-instance point :x 3 :y 4))
(slot-value p :x)
(defgeneric area (shape))
(defmethod area ((s point)) 0)
(area p)