next up previous

9.4.1.1 Active Instance Parameter

The term active instance refers to an instance which is responding to a message. All message-handlers have an implicit parameter called ?self which binds the active instance for a message. This parameter name is reserved and cannot be explicitly listed in the message-handler's parameters, nor can it be rebound within the body of a message-handler.

Example

CLIPS> (clear)
CLIPS> (defclass A (is-a USER) (role concrete))
CLIPS> (make-instance a of A)
[a]
CLIPS>
(defmessage-handler A print-args (?a ?b $?c)
    (printout t (instance-name ?self) " " ?a " " ?b
        " and " (length$ ?c) " extras: " ?c crlf))
CLIPS> (send [a] print-args 1 2)
[a] 1 2 and 0 extras: ()
CLIPS> (send [a] print-args a b c d)
[a] a b and 2 extras: (c d)
CLIPS>


next up previous