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.
--------------------------------------------------------------------

Reply via email to