rulesclipsclipspy

CLIPS Error: Illegal use of the module specifier in clipspy


I'm using clipspy. I want to define some module-rules to assert module-facts. The rule is based on facts from multiple modules. I get a CLIPS Error:

Illegal use of the module specifier

import clips 

env = clips.Environment()

env.build("(defmodule module1)")
env.build("(defmodule module2)")

env.build("(deftemplate module1::X (slot A) (slot B))")
env.build("(deftemplate module2::Y (slot C) (slot D))")

env.build("(defrule module2::rule1 (module1::X (A ?A) (B One) => (printout t hello crlf))")

print(env.find_rule("module2::rule1)

I learned that if I define a rule within a module using the fact from the same module, I don't get the error.

env.build("(defrule module1::rule1 (X (A ?A) (B One) => (printout t hello crlf))")

print(env.find_rule("module1::rule1))

I want to construct a rule using facts from multiple modules. I don't get the error when working with Jess but I run into this problem when using clipspy.


Solution

  • In CLIPS, you use the export and import keywords in the defmodule definition to share constructs between modules (section 10.4, Importing and Exporting Modules, in the Basic Programming Guide). A pattern can't reference a deftemplate in another module using a module specifier (e.g. module1::X).