next up previous

9.3.3.7 PatternMatch Reactivity Facet

Normally, any change to a slot of an instance will be considered as a change to the instance for purposes of pattern-matching. However, it is possible to indicate that changes to a slot of an instance should not cause pattern-matching. The reactive facet specifies that changes to a slot trigger patternmatching, and this is the default. The non-reactive facet specifies that changes to a slot do not affect pattern-matching.

Example

CLIPS> (clear)
CLIPS>
(defclass A (is-a USER)
  (role concrete)
  (pattern-match reactive)
  (slot foo (create-accessor write)
            (pattern-match non-reactive)))
CLIPS>
(defclass B (is-a USER)
  (role concrete)
  (pattern-match reactive)
  (slot foo (create-accessor write)
            (pattern-match reactive)))
CLIPS>
(defrule Create
  ?ins<-(object (is-a A | B))
=>
  (printout t "Create " (instance-name ?ins) crlf))
CLIPS>
(defrule Foo-Access
  ?ins<-(object (is-a A | B) (foo ?))
=>
  (printout t "Foo-Access " (instance-name ?ins) crlf))
CLIPS> (make-instance a of A)
[a]
CLIPS> (make-instance b of B)
[b]
CLIPS> (run)
Create [b]
Foo-Access [b]
Create [a]
CLIPS> (send [a] put-foo 1)
1
CLIPS> (send [b] put-foo 1)
1
CLIPS> (run)
Foo-Access [b]
CLIPS>


next up previous