Hi,
I've just noticed an interesting behavior of Jess.
I was working with a couple of classes like this:
public class X {
Object obj;
// getter and setter for obj
...
}
public class Y {
int i;
// getter and setter for i
...
}
Then in Jess I wrote:
(deftemplate X
Hi,
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))
(add ?fc)
This is the
Jess doesn't actually try to look for the I member until the code actually
runs, so it really has no choice but to accept the code as written. This really
isn't any different from how other dynamically typed languages behave; Java,
being a strongly/statically typed language that would not allow
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.