Fork me on GitHub
#clara
<
2016-04-15
>
devn00:04:37

@saicheong: I haven't done what you're describing. You could try it but something tells me that won't work.

devn00:04:07

I am heading out otherwise I'd help you out.

wparker02:04:33

@saicheong: I believe the problem with the constraint you have there is that you’re calling = with one argument, which always returns false. The symbol “this” in rule constraints is bound to the fact under consideration; I believe you need to test that “this” is equal to :exceed-cap. Example gist: https://gist.github.com/WilliamParker/9cafbe73b2c3b99153fd3fcfc8daa4c3

wparker03:04:30

One thing to keep in mind (without knowing anything about your use-case of course) is that one of the major optimizations of Clara (and the Rete algorithm it is based on more generally) is only testing facts against conditions that their type allows them to match. That is, if you inserted something that isn’t a Keyword into the example in the gist above, that equality check wouldn’t ever be tried. Checking equality against a keyword should be very, very fast though, just something to be aware of more generally. Of course, if your use case is small enough even thinking about that could be premature optimization.

saicheong03:04:46

@devn: Thanks. I'll try it out when I get some time.

saicheong03:04:58

@wparker: thanks for the tip on using 'this' in the expression. I'll try that out too.