next up previous

9.6.5 Deleting Instances

Sending the delete message to an instance removes it from the system. Within a message-handler, the delete-instance function (see section 12.16) can be used to delete the active instance for a message.

Syntax

(send <instance> delete)

9.6.6 Delayed Pattern-Matching When Manipulating Instances

While manipulating instances (either by creating, modifying, or deleting), it is possible to delay pattern-matching activities for rules until after all of the manipulations have been made. This can be accomplished using the object-pattern-match-delay function. This function acts identically to the progn function, however, any actions which could affect object pattern-matching for rules are delayed until the function is exited. This function's primary purpose is to provide some control over performance.

Syntax

(object-pattern-match-delay <action>*)

Example

CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
  (role concrete)
  (pattern-match reactive))
CLIPS>
(defrule match-A
  (object (is-a A))
=>)
CLIPS> (make-instance a of A)
[a]
CLIPS> (agenda)
0      match-A: [a]
For a total of 1 activation.
CLIPS> (make-instance b of A)
[b]
CLIPS> (agenda)
0      match-A: [b]
0      match-A: [a]
For a total of 2 activations.
CLIPS>
(object-pattern-match-delay
   (make-instance c of A)
   (printout t "After c..." crlf)
   (agenda)
   (make-instance d of A)
   (printout t "After d..." crlf)
   (agenda))
After c...
0      match-A: [b]
0      match-A: [a]
For a total of 2 activations.
After d...
0      match-A: [b]
0      match-A: [a]
For a total of 2 activations.
CLIPS> (agenda)
0      match-A: [d]
0      match-A: [c]
0      match-A: [b]
0      match-A: [a]
For a total of 4 activations.
CLIPS>


next up previous