Fork me on GitHub

Hi, I've started looking into Clara-Rules as part of a general exploration of Clojure, and I was wondering if it's possible to use it without having to make rulesets (edit: and queries, forgot to mention) as namespace-global variables? It feels incongruous with the style the core library and some external ones encourage. It also on-the-surface seems to have practical costs; for instance, I can't see how you would run multiple parallel simulations of custom-rule insertions and see how they affect firings, which could be convenient for a recommendation or testing system.


You can specify rules and queries (aka “productions”) to mk-session without anything tied to namespaces or vars


The productions themself though do get compiled via eval so they do have to be able to resolve symbols against the ns context they are evaled in. But that is likely what you'd already expect


You can see many examples of this type of ruleset creation in the tests such as

👍 1

Thanks for the link! I was just looking into the docs & tutorial and not finding any method to do this 🙂


not sure if this would help, but it might also be interesting:

👍 3

The pattern was indicated in the above example, but it's nice to know for sure that it works with def'd functions as well.


Particularly since now that I check, mk-session is actually a macro, so it was quite plausible that it wouldn't work, prior to your pointing that out!