一、
1、 (declare (salience20))声明了规则的优先级,数字越大优先级越高
2、 在规则同等优先级的情况下,事实按照堆栈的要求处理,后进先出。所以有:
CLIPS> (run)
third
second
二、
CLIPS> (clear)
CLIPS> (defrule first
(first first)
=>
(printout t "second" crlf))
CLIPS> (defrule second
(second second)
=>
(printout t "third" crlf))
CLIPS> (assert (firstfirst)(second second))
<Fact-2>
CLIPS> (run)
third
second
CLIPS> (clear)
CLIPS> (defrule first
(declare (salience 20))
(first first)
=>
(printout t "second"crlf))
CLIPS> (defrule second
(declare (salience 10))
(secondsecond)
=>
(printout t "third"crlf))
CLIPS> (run)
CLIPS> (assert (first first)(second second))
<Fact-2>
CLIPS> (run)
second
third
CLIPS>