clara-rules icon indicating copy to clipboard operation
clara-rules copied to clipboard

Support field accessor syntactic sugar within accumulators that use field accessors

Open EthanEChristian opened this issue 8 months ago • 0 comments

As discussed on https://github.com/oracle-samples/clara-rules/issues/498, clara supports the idea of syntactic sugar within the LHS constraints when accessing fields on both POJOs and Clojure Records.

However, the default accumulators do not expose the same contract with respect to the sugar provided. This can cause a bit of a gotcha in the sense that the user can avoid the distinction(POJO vs Record) within the constraints but must evaluate that distinction for the usage of the accumulator.

If possible I would like to extend the syntactic sugar portion of field access to all portions of the LHS if possible, such that Users need not make a distinction between the access pattern within the default accumulators.

For example, I would like the following rule:

(defrule some-java-fact-rule
  [?fact <- (acc/max #(.getValue %)) :from [MyObject]]
  =>
  (insert! ....))

to be expressible via something like:

(defrule some-java-fact-rule
  [?fact <- (acc/max value) :from [MyObject]]
  =>
  (insert! ....))

EthanEChristian avatar May 31 '24 17:05 EthanEChristian