expr-lang / expr

Expression language and expression evaluation for Go
https://expr-lang.org
MIT License
6.35k stars 408 forks source link

Running multiple expressions as one program #724

Open Tloe opened 3 weeks ago

Tloe commented 3 weeks ago

I have a concept of an expr expression collection in my backend where I run the same collection of expressions. A collection can potentially get quiet large. Is there a way to compile this into one expressions instead of having a program for each of the expressions? I do have a pool of vm's running, but still having to get and run all the programs separately would probably be a overhead.

antonmedv commented 3 weeks ago

Do you need outputs of those expressions? You can do something like this: [expr1, expr2, ...].

Tloe commented 3 weeks ago

I need a true/false response from each of the expressions only. So yes. An array response would work fine.

But what if expresssions programs are multiline and has variables.. can I just merge them like in your example and use semicolon between each \n?

Tloe commented 3 weeks ago

Actually, in some cases I would need something like [expr1 || expr2, expr3, expr4 || expr5,...]

antonmedv commented 3 weeks ago

It will work. As variables can be used inside arrays