其他 defmodules 如何从 MAIN 导入 defclass 和 detemplate
How can other defmodules import defclass and deftemplate from MAIN
最近看了一篇利用CLIPS实现自动检测的论文。其中显示了部分代码。它表明所有 defclasses 都属于 MAIN 模块。但是在其他 defmodules 中,他们的 defrules 可以使用这些 defclass 。在 advanced.docx 中,它表示 "the predefined MAIN module does not import or export any constructs"。并且我也在CLIPS界面作证
例如:
(defclass MAIN::telemetry-data
(is-a USER)
(slot name(type SYMBOL))
(slot predict-value(type SYMBOL NUMBER)))
(defrule discrimination::analog-data-discriminate
(object (is-a telemetry-data ) (name ?name))
=>
(printout t "name:"?name crlf)
)
那么defrule如何才能不出错地使用telemetry-data对象呢?
我知道我可以在判别模块中定义 class 以便正确执行。但我只是想知道是否有其他一些方法可以使用其他 defmodules 在 MAIN 模块中定义的构造。
非常感谢!
这是《基本编程指南》第 10.1 节的相关段落:
All of the predefined system classes (see section 9.2) belong to the
MAIN module. However, it is not necessary to import or export the
system classes; they are always in scope. Discounting the previous
exception, the predefined MAIN module does not import or export any
constructs. However, unlike other modules, the MAIN module can be
redefined once after startup or a clear command.
您所要做的就是重新定义 MAIN 模块:
CLIPS> (clear)
CLIPS> (defmodule MAIN (export ?ALL))
CLIPS>
(defclass MAIN::telemetry-data
(is-a USER)
(slot predict-value))
CLIPS>
(defmodule discrimination (import MAIN ?ALL))
CLIPS>
(defrule discrimination::analog-data-discriminate
(object (is-a telemetry-data) (name ?name))
=>
(printout t "name: " ?name crlf))
CLIPS>
您提供的代码片段还有其他问题。类型定义没问题,但是名称槽已经为 class.
预定义了
最近看了一篇利用CLIPS实现自动检测的论文。其中显示了部分代码。它表明所有 defclasses 都属于 MAIN 模块。但是在其他 defmodules 中,他们的 defrules 可以使用这些 defclass 。在 advanced.docx 中,它表示 "the predefined MAIN module does not import or export any constructs"。并且我也在CLIPS界面作证
例如:
(defclass MAIN::telemetry-data
(is-a USER)
(slot name(type SYMBOL))
(slot predict-value(type SYMBOL NUMBER)))
(defrule discrimination::analog-data-discriminate
(object (is-a telemetry-data ) (name ?name))
=>
(printout t "name:"?name crlf)
)
那么defrule如何才能不出错地使用telemetry-data对象呢? 我知道我可以在判别模块中定义 class 以便正确执行。但我只是想知道是否有其他一些方法可以使用其他 defmodules 在 MAIN 模块中定义的构造。
非常感谢!
这是《基本编程指南》第 10.1 节的相关段落:
All of the predefined system classes (see section 9.2) belong to the MAIN module. However, it is not necessary to import or export the system classes; they are always in scope. Discounting the previous exception, the predefined MAIN module does not import or export any constructs. However, unlike other modules, the MAIN module can be redefined once after startup or a clear command.
您所要做的就是重新定义 MAIN 模块:
CLIPS> (clear)
CLIPS> (defmodule MAIN (export ?ALL))
CLIPS>
(defclass MAIN::telemetry-data
(is-a USER)
(slot predict-value))
CLIPS>
(defmodule discrimination (import MAIN ?ALL))
CLIPS>
(defrule discrimination::analog-data-discriminate
(object (is-a telemetry-data) (name ?name))
=>
(printout t "name: " ?name crlf))
CLIPS>
您提供的代码片段还有其他问题。类型定义没问题,但是名称槽已经为 class.
预定义了