Java classes are totally optional in Jess -- in fact, templates and facts created directly from the Jess language are always more efficient.

If Jess were to store the properties of an object in a Map -- so that they were dynamic and extensible at runtime -- then it would be considerably slower, for the same reason that fully dynamic languages in which objects are maps of code and variables are slower than compiled languages. Construction of a fast Rete network requires knowing what properties are being dealt with. Think of a database in which all the data was stored as object-attribute-value triples -- would it be as fast as a database with fixed tables and columns?


On Aug 13, 2010, at 11:41 AM, Donald Winston wrote:

So I have to create a template and know all the identifiers before loading data into the fact base? This means I'll have to create java bean objects for all my data. Every time the data changes I'll have to modify the java classes. I don't believe in creating objects for things that have little or no behavior. That's what Maps and Lists are for.

I suppose I could generate a "init-facts.clp" file when my app starts up and load it along with the rules.

On Aug 13, 2010, at 11:18 AM, Ernest Friedman-Hill wrote:

Basically for the same reason that you can't say something like this in Java:

String theMethodName = "toString";
String myString = myObject.(theMethodName)();

but instead you have to use reflection to find the method "toString" and call it using the Method object. The compiler needs to know the correct template to use to compile the code, and it can't do that if the name of the template is in a variable.

Now, you may ask *could* it work the way you want? Indeed, it could -- but it doesn't at this time. We've talked in the past about allowing this kind of thing, and it has its pros and cons.


On Aug 13, 2010, at 11:05 AM, Donald Winston wrote:

Can anyone explain to me why this does not work? Why can't I use

(deffacts initial-facts
"Facts to trigger a few appropriate salient initialization rules."
(assert-request-parameters))

(defrule assert-request-parameters-rule
"Assert stored data one time."
(declare (salience 100))
?x <- (assert-request-parameters)
      =>
(foreach ?key (((fetch request-parameter-map) keySet) iterator)
(build str-cat "(assert (" ?key " " ((fetch request- parameter-map) get ?key) "))")) ; why not (assert (?key ((fetch request-parameter-map) get ?key))))
   (retract ?x))

(bind ?map (new java.util.HashMap))
(?map put one 1)
(?map put two 2)
(?map put three 3)
(store request-parameter-map ?map)
(reset)
(facts)
(run)
(facts)

Jess, the Rule Engine for the Java Platform
Copyright (C) 2008 Sandia Corporation
Jess Version 7.1p2 11/5/2008

This copy of Jess will expire in 207 day(s).
f-0   (MAIN::initial-fact)
f-1   (MAIN::assert-request-parameters)
For a total of 2 facts in module MAIN.

f-0   (MAIN::initial-fact)
For a total of 1 facts in module MAIN.

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com '
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov .
--------------------------------------------------------------------






--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov .
--------------------------------------------------------------------

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            ejfr...@sandia.gov
Livermore, CA 94550                             http://www.jessrules.com





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to