why do rules have to have fact-type? e.g. Person
here:
[?person <- Person (= first-name "Alice") (= ?last-name last-name)]
;; or here
[Person (= ?name1 name) (= ?age1 age)]
how does engine implementation leverages that? it seems like having datomic-like datalog api would be somewhat more uniform or convenient, or ...?
@misha in essence Clara, given facts, finds the types that match that fact and looks up the rules with conditions on that type. Note that “matching the type” includes conditions matching on an ancestor of the fact’s type.
This improves performance when there are lots of rules - a fact doesn’t have to be evaluated against rules that its’ type won’t allow it to match
There’s some tangentially related discussion of this at http://www.clara-rules.org/docs/fact_type_fn_perf/
@misha also, there are alternatives to how you could structure a DSL over this - Clara just has this one as the default. It isn’t necessarily trivial to extend things, but there are examples of at least datom-like datom support with https://github.com/clyfe/clara-eav