next up previous

9.4.3 Daemons

Daemons are pieces of code which execute implicitly whenever some basic action is taken upon an instance, such as initialization, deletion, or reading and writing of slots. All these basic actions are implemented with primary handlers attached to the class of the instance. Daemons may be easily implemented by defining other types of message-handlers, such as before or after, which will recognize the same messages. These pieces of code will then be executed whenever the basic actions are performed on the instance.

Example

CLIPS> (clear)
CLIPS> (defclass A (is-a USER) (role concrete))
CLIPS>
(defmessage-handler A init before ()
    (printout t "Initializing a new instance of class A..."
              crlf))
CLIPS> (make-instance a of A)
Initializing a new instance of class A...
[a]
CLIPS>


next up previous