Certain RHS actions, such as retract and unmakeinstance, operate on an entire pattern CE. To signify which fact or instance they are to act upon, a variable can be bound to the factaddress or instanceaddress of a pattern CE. Collectively, factaddresses and instanceaddresses bound on the LHS of a rule are referred to as patternaddresses.
Syntax
<assigned-pattern-CE> ::= ?<variable-symbol> <- <pattern-CE>
The left arrow, <, is a required part of the syntax. A variable bound to a factaddress or instanceaddress can be compared to other variables or passed to external functions. Variables bound to a fact or instanceaddress may later be used to constrain fields within a pattern CE, however, the reverse is not allowed. It is an error to bind a varible to a not CE.
Examples
(defrule dummy (data 1) ?fact <- (dummy pattern) => (retract ?fact)) (defrule compare-facts-1 ?f1 <- (color ~red) ?f2 <- (color ~green) (test (neq ?f1 ?f2)) => (printout t "Rule fires from different facts" crlf)) (defrule compare-facts-2 ?f1 <- (color ~red) ?f2 <- (color ~green&:(neq ?f1 ?f2)) => (printout t "Rule fires from different facts" crlf)) (defrule print-and-delete-all-objects ?ins <- (object) => (send ?ins print) (unmake-instance ?ins))