nikku / feelin

A DMN FEEL parser and interpreter written in JavaScript
MIT License
38 stars 8 forks source link

Does evaluate() cache a parsed expression? #67

Closed ekzobrain closed 6 months ago

ekzobrain commented 6 months ago

I execute expressions with evaluate() in a loop with up to a thousand iterations. Usually template or epression languages have separate parse and evaluate methods, the first is needs to execute only once, and the second only evaluated already parse epression with current context (variables). Is this possible with feelin or does it persorm any internal AST cahing per expression?

nikku commented 6 months ago

DMN FEEL is context sensitive. I stressed earlier how this leads to interesting effects.

You can cache executions, but will run into trouble if the context (any input data) changes.

ekzobrain commented 4 weeks ago

Interpreter class is not exported, so I cannot use it directly. May you also export it? I need to cache prepared execution trees because I need to render compatible (by structure) context multiple times...

nikku commented 4 weeks ago

How do you enforce an equal structure?

ekzobrain commented 3 weeks ago

I use FEEL to render items (values and labels) in dynamic select form fields. So I have a FEEL expression for label and an expression for value. Context is like this:

options = [
  { name: "xxx", code: "yyy", "other": "zzz" },
  // repeated 100 times, for example
]

So I would like to compile expression only once for label and for value and then render it for all 100 options. I am sure that all options have the same structure.