next up previous

9.3.4 Messagehandler Documentation

COOL allows the user to e the messagehandlers for a class within the defclass statement. These declarations are for only and are ignored by CLIPS. The defmessagehandler construct must be used to actually add messagehandlers to a class. Messagehandlers can later be added which are not documented in the defclass.

Example

CLIPS> (clear)
CLIPS>
(defclass rectangle (is-a USER)
    (slot side-a (default 1))
    (slot side-b (default 1))
    (message-handler find-area))
CLIPS>
(defmessage-handler rectangle find-area ()
    (* ?self:side-a ?self:side-b))
CLIPS>
(defmessage-handler rectangle print-area ()
    (printout t (send ?self find-area) crlf))
CLIPS>


next up previous