The *real* way to add shadow facts is using the "definstance" function. It has
a number of options that aren't available with "add". The "add" function was
added to Jess to support the simplified semantics of JSR-94 (the javax.rules
API) but the intent is that most Jess users will use "definstance."
Asserting a fact directly from a from-class template is like buying a doghouse;
you don't expect to go out the next morning and find that somehow it has a dog
in it, right? It's certainly something you can do, but in normal life it's not
very useful; usually you get a doghouse when you buy a dog, and "add" and
"definstance" will both get you a doghouse for your Java object "dog"
From: owner-jess-us...@sandia.gov [mailto:owner-jess-us...@sandia.gov] On
Behalf Of Henrique Lopes Cardoso
Sent: Friday, May 10, 2013 4:54 AM
Subject: JESS: [EXTERNAL] Adding facts that are instances of from-class
I am concerned with the at least two different ways in which you can add, to
working memory, facts that are instances of from-class deftemplates.
Lets say I have:
(deftemplate FC (declare (from-class FC)))
I can add a shadow fact like this:
(bind ?fc (new FC))
This is the general approach described in Section 5.3.2 of the Jess manual.
But I can also simply go like:
I guess in this case I do not get a shadow fact, since the OBJECT slot is nil.
So, my question is: if my facts are not supposed to be changed from Java code,
is there any difference in using each of these approaches?
Section 5.3 from the Jess manual does not even mention that instances of
from-class deftemplates can be created using the second approach above.