Fork me on GitHub
#clara
<
2015-12-15
>
devn00:12:51

@ryanbrush: Is there any way to reference elements of the rule itself, within the rule?

devn00:12:32

@ryanbrush: for instance, it would be cool if I could bind $?name $?docstring or $?lhs

devn00:12:31

So I could push forward some additional metadata about the rule which inserted a fact, for instance

ryanbrush01:12:37

@devn It's not in the public API, but the clara.rules.engine/rule-context dynamic var is populated when a rule is firing. So you could do something like (get-in clara.rules.engine/rule-context [:node :production]) , which would have :name and :doc properties.

ryanbrush01:12:24

@devn It would be simple to add a (current-rule) function that just returns that to the public namespace as well. I can see how it would be useful.

devn01:12:55

Do defrules and queries allow meta on them when defining them?

devn01:12:10

like (defrule ^{:cool true} "foo" ... => ...)

devn01:12:25

err forgot the name there

devn01:12:28

but you catch my drift

ryanbrush01:12:06

It doesn't use meta (but that would be add-able). This might be a good case for rule properties. You could do (defrule my-rule {:cool true} "doc here" ... => ...) This is how rule salience is set but you can put arbitrary properties there.

ryanbrush01:12:23

See the salience example for the structure: http://www.clara-rules.org/docs/conflictsalience/

devn01:12:35

ah, just discovered that while reading the source

devn01:12:40

please excuse my laziness

devn01:12:47

I ran into a situation with salience and accumulators. I don't have a simple repro as it was a month ago or so now

devn01:12:04

it was a custom accumulator, so probably a good chance it was my fault

devn01:12:21

but i was curious if you were generally aware of any problem that might exist when accumulating and using salience

ryanbrush01:12:17

@devn I'm not aware of any issues with salience and accumulators, although we've used both pretty extensively. If you are able to reproduce something we'd definitely want to track it down.