Hi,
I am confused about using facts in different modules. I tried to put in
this message some exemplifying cases...
In the Jess documentation (more specifically in "The Jess Language"
section) the following is written:
+If you don't specify a module, all deffacts, templates and rules
you define will automatically become part of the current module;
Here is a piece of code with comments that indicate the tricky part:
;;;;;;;;;;
(deftemplate x
(slot x1)
)
(defrule r1 (first-fact) => (printout t "found first-fact!!!" crlf))
(defmodule m)
(deffacts m-facts
(first-fact) ; this fact is created in MAIN
(second-fact) ; this fact is created in m
(x (x1 qwe)) ; this fact is created in MAIN
)
(reset)
;;;;;;;;;;
This is confusing, because after creating module m it becomes the
current module, and therefore all facts should be created in m.
I guess that the facts are created where the templates are defined (x
explicitly and first-fact implicitly through rule r1)...
Now, if I use the deffacts construct as follows:
(deffacts m::m-facts
(first-fact) ; this fact is created in MAIN
(second-fact) ; this fact is created in m
(x (x1 qwe)) ; this fact is created in MAIN
)
Mmmm... Looks like even if I indicate the module in the deffacts
construct, I get the same behaviour...
Then I tried this:
(deffacts m-facts
(m::first-fact) ; this fact is created in m
(second-fact) ; this fact is created in m
(x (x1 qwe)) ; this fact is created in MAIN
)
And then this:
(deffacts m-facts
(m::first-fact)
(second-fact)
(m::x (x1 qwe))
)
I get an error in this last one... template x is not recognized inside
module m. Does this mean I cannot create x facts inside m?
That is, facts with deftemplates defined in main cannot be asserted in
other modules?
I then tried to use assert (with m as the current module).
(assert (first-fact)) ; this fact is asserted in MAIN
(assert (m::first-fact)) ; this fact is asserted in m
(assert (second-fact)) ; this fact is asserted in m
(assert (x (x1 qwe))) ; this fact is asserted in MAIN
(assert (m::x (x1 qwe))) ; ERROR as before...
Are all these results ok, is there a bug in Jess, or am I missing something?
Thank you in advance.
Henrique
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------