(defclass MAIN::ROOT
(is-a USER)
(role abstract)
(slot amount (type NUMBER) (default 0)))
(defclass MAIN::A
(is-a ROOT)
(role concrete)
(slot detail-type (storage shared)))
(defmessage-handler MAIN::A create before ()
(bind ?self:detail-type the-a-type)
(printout t "Constructor " crlf))
(defmessage-handler MAIN::ROOT put-amount before (?value)
(bind ?old-value (send ?self get-amount))
(if (numberp ?old-value) then
(printout t "Subtract old amount from " (send ?self get-detail-type) " " ?old-value crlf)
else
(printout t "ROOT put-amount before ignored" crlf)))
(defmessage-handler MAIN::ROOT put-amount after (?value)
(bind ?new-value (send ?self get-amount))
(if (numberp ?new-value) then
(printout t "Add new amount to " (send ?self get-detail-type) " " ?new-value crlf)
else
(printout t "ROOT put-amount after ignored" crlf)))
(definstances MAIN::instances
([inst-1] of A (amount 25))
([inst-2] of A (amount 1000)))
Constructor
ROOT put-amount before ignored
Add new amount to the-a-type 25
Constructor
ROOT put-amount before ignored
Add new amount to the-a-type 1000