Hi there, I personally think that this actually works around the basic idea of a fact/rule system like Jess - a rule fires whenever all its conditions are met and this will be tested whenever the facts in question are modified. In other words - the behavior as it is right now is absolutely correct.
What I would find favourable is a modified behavior in a way, that a rule gets activated by a modified fact *only* if a slot applicable to the rule had been changed, i.e. in this example > (defrule my-rule > ?fact <- (fact (slot ?x)) > => > (modify ?fact (slot (+ ?y 1))))" should not fire again, but only if x has changed. I know, that this is actually something different than initially proposed, but well ... Regards, tge [EMAIL PROTECTED] wrote: > > Hi Folks, > > Very often, people post questions equivalent to the following to this > list: > > "Why does this cause an infinite loop? > > (defrule my-rule > ?fact <- (fact (slot ?x)) > => > (modify ?fact (slot (+ ?x 1))))" > > and then we have to explain why this happens, and how to avoid it > (it's a side-effect of how the Rete algorithm works, and you can avoid > it by making the rule more specific, so the modified fact won't match > anymore.) > > Here's a proposed feature that would provide an alternative way to > avoid the infinite loop -- and I think a more powerful way: "one-shot" > rules. Basically, the feature is this: if you declare a rule like > this: > > (defrule my-rule > (declare (one-shot TRUE)) > ?fact <- (my-fact (slot ?x)) > => > (modify ?fact (slot (+ ?x 1)))) > > then my-rule will keep track of all the combinations of facts it has > ever fired on, and will never fire on the same combination twice, so > that, for example, my-rule would fire exactly once for each my-fact. > > The performance overhead would bne relatively small, as the lists of > past firings could be kept in a hash table and so you'd just see > amortized constant-time overhead for each potential activation of a > one-shot rule (and no impact at all for non-one-shot rules.) > > Does this sound like a useful feature? Do the semantics sound > reasonable? Any suggestions or refinements? Should there be a global > switch to make ALL rules one-shot? > > --------------------------------------------------------- > Ernest Friedman-Hill > Distributed Systems Research Phone: (925) 294-2154 > Sandia National Labs FAX: (925) 294-2234 > PO Box 969, MS 9012 [EMAIL PROTECTED] > Livermore, CA 94550 http://herzberg.ca.sandia.gov > > -------------------------------------------------------------------- > 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] > -------------------------------------------------------------------- -- ........................................................ Thomas Gentsch -------------- Phone: +49 711 486948 E-mail: [EMAIL PROTECTED] Mobil: +49 173 6620507 WWW: www.e-tge.de Fax: +49 711 4687889 www.blue-elephant-systems.com ........................................................ -------------------------------------------------------------------- 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] --------------------------------------------------------------------