next up previous

10.5 IMPORTING AND EXPORTING FACTS AND INSTANCES

Facts and instances are ìownedî by the module in which their corresponding deftemplate or defclass is defined, not by the module which creates them. Facts and instances are thus visible only to those modules which import the corresponding deftemplate or defclass. This allows a knowledge base to be partitioned such that rules and other constructs can only ìseeî those facts and instances which are of interest to them. Note that the initial-fact deftemplate and the INITIAL-OBJECT defclass must explicitly be imported from the MAIN module. Rules which have the initial-fact or initial-object pattern added to their LHS (such as a rule thats first CE is a not CE) will not be activated unless the corresponding construct for the pattern is imported.

Example

CLIPS> (clear)
CLIPS> (defmodule A (export deftemplate foo bar))
CLIPS> (deftemplate A::foo (slot x))
CLIPS> (deftemplate A::bar (slot y))
CLIPS> (deffacts A::info (foo (x 3)) (bar (y 4)))
CLIPS> (defmodule B (import A deftemplate foo))
CLIPS> (reset)
CLIPS> (facts A)
f-1     (foo (x 3))
f-2     (bar (y 4))
For a total of 2 facts.
CLIPS> (facts B)
f-1     (foo (x 3))
For a total of 1 fact.
CLIPS>

10.5.1 Specifying InstanceNames



next up previous