Fork me on GitHub
#clara
<
2018-02-06
>
dave.dixon02:02:51

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.

mikerod15:02:40

@dave.dixon not sure if there are any docs on it

mikerod15:02:12

that’s the best I’ve found as far as docs on it

mikerod15:02:27

(didn’t do an exhaustive search)

wparker15:02:35

@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

dave.dixon15:02:49

@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"?

wparker15:02:11

In the case of :not :exists there isn’t much reason to write it like that though, as I mentioned on the issue

dave.dixon15:02:43

Ah. Okay, I thought maybe I was just writing the expression, wrong. I'll take a look at the discussion.

wparker15:02:47

as a general API concern, it is something that seems like it should work.. but haven’t gotten around to fixing it

dave.dixon16:02:53

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

dave.dixon21:02:04

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.