Is there any documentation of the :exists
feature? I saw some discussion about it on google groups and maybe in an issue, but haven't found much else.
@dave.dixon not sure if there are any docs on it
https://github.com/cerner/clara-rules/issues/130 has some discussion
that’s the best I’ve found as far as docs on it
(didn’t do an exhaustive search)
@dave.dixon I don’t see any docs on it based on a search for “exists” in the clara-site repo. Having doc would be desirable. In the meantime it is really a pretty form of syntax sugar - you can just mentally make the substitution the compiler does at https://github.com/cerner/clara-rules/blob/master/src/main/clojure/clara/rules/compiler.clj#L618 if you’re trying to understand the behavior
@wparker Thanks. So looking at that, [:not [:exists ...]]
should work as expected, i.e. that "no fact satisfying the conditions exists" as opposed to "maybe some fact exists that doesn't satisfy the conditions"?
Unfortunately not at the moment; see https://github.com/cerner/clara-rules/issues/329
In the case of :not :exists there isn’t much reason to write it like that though, as I mentioned on the issue
Ah. Okay, I thought maybe I was just writing the expression, wrong. I'll take a look at the discussion.
as a general API concern, it is something that seems like it should work.. but haven’t gotten around to fixing it
It does seem to work. I was having some issues and thought this may be the culprit, but it was other things (which had nothing to do with clara per se). I was a little suspicious of that binding inside the negation as well, but is seems to operate as intended, i.e. "There is no Request fact equal to the Request entry on the Response fact".
It looks like the current behavior of parameterized queries is to just return an empty seq if all of the arguments are not bound in the call to query
. It would be useful sometimes if leaving out a parameter just treated it as unbound, though I think you could only get away with this when the parameters are used in simple equality constraints, e.g. [?:foo] [Foo (= ?foo foo)]
. I can get this behavior by wrapping query
, but was wondering if there was a way to achieve it directly in clara.