(defclass thing ()
   ((weight    :initform ’(0 kg)
               :accessor weightof
               :initarg :weight)))
(defclass animal (thing)
   ((specie    :accessor specieof
               :initarg :spec)
   (sex        :accessor sexof
               :initform ’m
               :initarg :sex)))
(defclass possession (thing)
   ((owner     :accessor ownerof
               :initform ’nnn)
   (cost       :accessor costof
               :initform ’(0 bucks)
               :initarg :cost))
)
(defclass person (animal)
   ((specie    :initform ’human)
   (name       :initarg :thename
               :accessor nameof)))
(defclass pet (animal possession)
   ((nick      :initarg :thenick
               :accessor nickof)
   (specie        :initform ’cat)))
   
(defmethod act :before ((p pet))
   (print "Cat mews"))
(defmethod act :after ((p pet))
   (print "Cat turns"))
(defmethod act :around ((p pet))
   (progn (print "You have a cat") (call-next-method)))
   
(defmethod act ((p animal))
   (progn (print "Animal is close to you") (call-next-method)))
(defmethod act :before ((p animal))
   (print "You see an animal"))
(defmethod act :after ((p animal))
   (print "You send the animal off"))
(defmethod act :around ((p animal))
   (progn (print "You don’t like wild animals") (call-next-method)))
   
(defmethod act ((p possession))
   (progn (print "You test your property") (call-next-method)))
(defmethod act :before ((p possession))
   (print "You see your property"))
(defmethod act :after ((p possession))
   (print "You are pleased by your property"))
(defmethod act :around ((p possession))
   (progn (print "You admire your property
                       if it is in good state") (call-next-method)))
                       
(defmethod act ((p thing))
   (print "You take the thing"))
(defmethod act :before ((p thing))
   (print "You see something"))
(defmethod act :after ((p thing))
   (print "You identified this thing"))
(defmethod act :around ((p thing))
   (progn (print "You are not interested
                       in strange things") (call-next-method)))
                       
(act (make-instance ’pet :thenick "Viola" :cost ’(25 kop)))
    

Листинг 8.6.1. Взаимодействие дополнительных спецификаций методов в CLOS с упорядочением типов классов
Закрыть окно