‘ункциональное программирование

       

You are pleased by your


(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 с упор€дочением типов классов
«акрыть окно



—одержание раздела