This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-29
Channels
- # ai (2)
- # beginners (12)
- # bitcoin (1)
- # boot (41)
- # chestnut (5)
- # cider (9)
- # clara (24)
- # cljs-dev (11)
- # clojure (107)
- # clojure-dev (2)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-russia (10)
- # clojure-spec (19)
- # clojure-uk (71)
- # clojurescript (121)
- # cursive (3)
- # data-science (7)
- # datacrypt (1)
- # datomic (72)
- # docs (7)
- # duct (2)
- # emacs (3)
- # ethereum (1)
- # figwheel (1)
- # fulcro (58)
- # graphql (16)
- # hoplon (9)
- # jobs (2)
- # jobs-rus (1)
- # lein-figwheel (1)
- # leiningen (25)
- # luminus (2)
- # lumo (5)
- # off-topic (6)
- # onyx (22)
- # pedestal (3)
- # portkey (1)
- # proton (2)
- # re-frame (7)
- # remote-jobs (1)
- # ring-swagger (3)
- # rum (2)
- # shadow-cljs (38)
- # specter (7)
- # yada (30)
In my early experimentation with clara I ended up with infinite loops when firing rules. They were non-terminating due to rules which are directly or indirectly affected by the facts they insert.
I went looking for documentation around this. I can't see anything apart from an issue about a :no-loop flag.
Direct question: is Clara smart enough to avoid infinite loops based on bad rules?
@olivergeorge are you asking if Clara can solve the Halting problem?
There is no way to know that something that âlooks like a cycleâ at runtime isnât going to eventually stop cycling
Clara could assume if a cycle of rules was happening âtoo many timesâ that it should stop
In Drools (popular Java-based rules engine that I often reference since it was used a lot in the industry) there was a âfire until haltâ sort of method I believe it was called. This allowed to have a sort of âtimeoutâ feature that the rules would stop if they reached a certain threshold of time, steps, # rule firings, etc. So something like that is feasible to implement, but not in Clara right now.
I do tend to try to avoid using something like :no-loop
too and instead setup the rules in a way where they logically wonât loop. :no-loop
starts to go against the logical truth maintenance in some cases.
Understandably, there are cases where it is sort of hard to think about how you can make the rule logic you want not form a logical loop.
There is work logged for Clara to assume by default that after a certain number of iterations of looping that the rules were written incorrectly and throw an exception: https://github.com/cerner/clara-rules/issues/275
I agree with @mikerod âs comments - perhaps another way of thinking about it is that if you just write a normal infinitely recursive function, Clojure or any other programming language can throw a StackOverflowException but canât automatically recover from it - the language would have to guess what the programmer actually wanted to do in order to accomplish that
I see Claraâs handling of infinitely looping rules as similar - thereâs no way for Clara to guess what the user actually wanted to do
Is there a way for someone to override what is printed when an exception is thrown? I have a fact with a very large map and when an exception is thrown it tries to print it as a binding and the REPL basically becomes unresponsive.
I think printing the bindings directly in the exception message can be a little ambitious since sometimes there are really large bindings. They can be really big due to things like acc/all
too