如果找到事实,CLIPS 的 do-for-fact 的 return 价值是多少?

What's the return value of CLIPS' do-for-fact if fact has been found?

CLIPS reference manual关于do-for-fact的解释:

If a fact-set satisfies the query, the specified action is executed, and the function is immediately terminated. The return value is the evaluation of the action. If no fact-set satisfied the query, then the return value is the symbol FALSE.

但是,我找不到任何关于 "evaluation of the action" 一般含义的详细信息。

假设 do-for-fact 总是 returns 一个不等于 FALSE 的值,如果已找到一个事实是否安全?

下面的代码片段是否正确?

(if (not (do-for-fact ((?p1 girl boy woman man)
                       (?p2 girl boy woman man)
                       (?p3 girl boy woman man))
                      (and (= ?p1:age ?p2:age ?p3:age)
                           (neq ?p1 ?p2)
                           (neq ?p1 ?p3)
                           (neq ?p2 ?p3))
                      (printout t ?p1:name " " ?p2:name " " ?p3:name crlf)))
then
  (printout t "Nobody found" crlf)
)

Action引用函数语法的BNF描述:

(do-for-fact <fact-set-template> <query> <action>*)

此动作术语与 deffunction 主体中使用的术语相同:

(deffunction <name> [<comment>]
   (<regular-parameter>* [<wildcard-parameter>]) <action>*)

两种情况下的 return 值都是最后评估的操作。如果最后一个操作评估的 return 值为 FALSE,那么 do-for-fact 函数将 return 值为 FALSE 就像没有满足查询的事实集一样。

在您的示例中,打印输出函数没有 return 值,该值被 not 函数视为非 FALSE 值,因此它将按您预期的方式工作

CLIPS> (printout t)
CLIPS> (not (printout t))
FALSE
CLIPS> 

如果您在打印输出调用后包含了符号 FALSE,那么无论事实集是否满足查询,do-for-fact 调用的 return 值将始终为 FALSE。

(printout t ?p1:name " " ?p2:name " " ?p3:name crlf)
FALSE))