Hi,
a few days ago I posted a question concerning the use of modules and so far I did not get
any answer. Is there really no one who could help me to figure out what is wrong with
the following example?
Felix
Here an interesting issue. (I hope)
Assume the rules are structured into 3 modules (MAIN, A, and B) which contain statements to assert ordered facts as shown in this example:
;
; c:/jess/test/A.clp
;
(defmodule A)
(defrule forA
(MAIN::initial-fact)
=>
(assert (testfact A in A))
(assert (testfact B in A)))
;
; c:/jess/test/B.clp
;
(defmodule B)
(defrule forB
(initial-fact)
(MAIN::testfact B in MAIN) ; <==== This causes the trouble
=>
(assert (testfact A in B))
(assert (testfact B in B)))
;
; c:/jess/test/MAIN.clp
;
(batch c:/jess/test/A.clp)
(batch c:/jess/test/B.clp)
(reset)
(set-current-module MAIN)
(assert (testfact A in MAIN))
(assert (testfact B in MAIN))
(focus A B)
Module B contains a rule that matches a fact from module MAIN (see the mark). After loading MAIN.clp and running this little program jess displays the following facts:
-----Result with the marked statement
Jess> (facts *)
f-0 (MAIN::initial-fact)
f-1 (MAIN::testfact A in MAIN)
f-2 (MAIN::testfact B in MAIN)
f-3 (A::testfact A in A)
f-4 (A::testfact B in A)
f-5 (MAIN::testfact A in B)
f-6 (MAIN::testfact B in B)
For a total of 7 facts.
Jess>
f-5 and f-6 should not be facts in module MAIN but in module B. After removing that marked pattern from the rule ForB, facts are created as expected:
-----Result without the marked statement
Jess> (facts *)
f-0 (MAIN::initial-fact)
f-1 (MAIN::testfact A in MAIN)
f-2 (MAIN::testfact B in MAIN)
f-3 (A::testfact A in A)
f-4 (A::testfact B in A)
f-5 (B::testfact A in B)
f-6 (B::testfact B in B)
For a total of 7 facts.
Jess>
Can anybody tell me what I am doing wrong here?
Felix
Felix Bachmann
Carnegie Mellon
Voice: +1 (412) 268 6194
Software Engineering Institute
FAX: +1 (412) 268 5758
Pittsburgh, PA 15213
