Fork me on GitHub
#clara
<
2019-06-26
>
misha19:06:55

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)]

misha19:06:32

how does engine implementation leverages that? it seems like having datomic-like datalog api would be somewhat more uniform or convenient, or ...?

wparker20:06:56

@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.

wparker20:06:27

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

wparker20:06:00

There’s some tangentially related discussion of this at http://www.clara-rules.org/docs/fact_type_fn_perf/

mikerod20:06:04

@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