precept
precept copied to clipboard
Can't express :type and a binding on attribute simultaneously
(cr/defrule remove-older-unique-identity-facts
{:super true :salience 100}
[:unique-identity (= ?a1 (:a this)) (= ?t1 (:t this))]
[?fact2 <- :unique-identity (= ?a1 (:a this)) (= ?t2 (:t this))]
[:test (> ?t1 ?t2)]
=>
(trace (str "SCHEMA MAINT - :unique-identity" ?t1 " is greater than " ?t2))
(retract! ?fact2))
Currently no way to do this using our positional syntax. Not sure what a good syntax would be for this.
Expression reads in English as something like "when there's a unique-identity type of fact, bind the value of its attribute to ?a1".
Possibilities for new syntax:
[[_ (and :unique-identity ?a1) _ ?fact-id]]
[[_ [:unique-identity :as ?a1] _ ?fact-id]]
We can do this with current syntax. Not sure if performance is worse.
[[?e1 :unique-identity _ ?fact-id]]
[[?e1 ?a1 _ ?fact-id]]