This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-28
Channels
- # announcements (14)
- # autochrome-github (1)
- # babashka (4)
- # beginners (151)
- # biff (1)
- # calva (24)
- # cider (13)
- # clara (13)
- # clj-commons (1)
- # cljs-dev (24)
- # clojure (50)
- # clojure-europe (20)
- # clojure-france (13)
- # clojure-nl (4)
- # clojure-norway (12)
- # clojure-spec (43)
- # clojure-uk (6)
- # clojurescript (30)
- # cursive (2)
- # datahike (9)
- # editors (6)
- # emacs (2)
- # fulcro (29)
- # google-cloud (20)
- # graphql (2)
- # humbleui (2)
- # jobs (2)
- # juxt (4)
- # kaocha (5)
- # lsp (14)
- # malli (5)
- # membrane (10)
- # off-topic (39)
- # pathom (21)
- # polylith (10)
- # rdf (8)
- # reagent (4)
- # remote-jobs (3)
- # reveal (18)
- # shadow-cljs (27)
- # spacemacs (7)
- # tools-deps (30)
Maybe not an appropriate question here i really like clara rules and would love to use it in scala has anyone tried it in scala or even just through java ?
@petr I think abstractly, not really. However, there are ways to write rules that perform better by reducing the set of facts needed to be tested for matches.
I will add on to what Mike said, there are scenarios where it can be advantageous to order constraints in an order that is consistent with the performance of the check. Example:
(defrule a-rule
[Fact
(a-quick-check)
(a-slow-check)]
=>
(<do things here>))
Due to the implementation of clara, “In most cases, those not being joined to other facts”, most constraints are simply “plopped” into an if
block.
So, in short… i guess i would recommend ordering constraints similar to how you would if you are writing an explicit if
yourself…
That being, if you know one check is “cheaper” put it first in an attempt to short circuit the following logic.
That all being said… i might just be being pedantic with the terminology of Condition
vs. Constraint
.
edit: or
-> if
I think “Condition” is better to refer to [Fact <constraints>]
Where then, “Constraint”s refer to the filter within the “Condition”.