0.7.0
This release makes it much nicer to detect and fix infinite loops. Previously, you just got an ugly StackOverflowException
with a very long and unhelpful stack trace. Now, it actually detects which rules are involved in the infinite loop and includes them in the error message.
For example, if you run the code in the "Avoiding infinite loops" section of the README, but you remove the {:then false}
, the exception now tells you exactly which rule is the culprit:
Recursion limit hit.
This may be an infinite loop.
The current recursion limit is 16 (set by the :recursion-limit option of fire-rules).
Cycle detected! :odoyle.readme/move-player is triggering itself.
Try using {:then false} to prevent triggering rules in an infinite loop.
Infinite loops can also form when several rules call each other in a cycle. O'Doyle is now smart enough to detect this and show the whole cycle in the error message:
Recursion limit hit.
This may be an infinite loop.
The current recursion limit is 16 (set by the :recursion-limit option of fire-rules).
Cycle detected! :odoyle.rules-test/rule6 is triggering itself.
Cycle detected! :odoyle.rules-test/rule1 -> :odoyle.rules-test/rule2 -> :odoyle.rules-test/rule3 -> :odoyle.rules-test/rule1
Cycle detected! :odoyle.rules-test/rule4 -> :odoyle.rules-test/rule5 -> :odoyle.rules-test/rule4
Try using {:then false} to prevent triggering rules in an infinite loop.
Infinite loops are probably the main sharp edge of using O'Doyle so methinks this will make it a lot less of a drag. In fact, infinite loops might actually be fun now. Sometimes I make them on purpose just to see that beautiful error message. Not even joking.
Thank you to Clojurists Together for supporting this release.