Why Modify
Why Modify
Why Modify?
I now add one rule to my system called accelerate car
Notice that I have the no-loop attribute turned off
If I were to run a test scenario where I place one Car object into
working memory, what would you expect to happen?
Why Modify?
Since the no-loop attribute is off, you might expect this to result in an
infinite loop. However, as you can see below, the rule is only activated
one time.
Why? The rule engine is never informed that anything has changed in
working memory.
Why Modify?
If I change the rule by adding update or modify, then I also need to set
the no-loop attribute to true. Why?
Every update or modify command will inform the rule engine to do a reevaluation of the fact since something has changed on fact.
So in this case, no-loop must be set to prevent an infinite loop.
Why Modify?
To be clear, no-loop is not the only way to prevent an infinite loop. I
would suggest that the use of no-loop should be a last resort.
The following rule is one example of how to stop the infinite loop without
using the no-loop attribute.