You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I saw this library and that it supports custom operators and functions I very much wanted to include it in my project as an expression evaluator, but sadly could because it is very (unnecessarily) limited for only math. Mainly because:
expression must be provided in builder constructor (unnecessarily) when it is only neede at build() call. You might want to reuse the same custom Op or Func configuration (same builder) on multiple expressions, now you have to re-create it for each expression
arguments can only be doubles (this is bad even for math, as BigDecimal would have infinite precision)
evaluates only to double (again, BigDecimal would be more precise even if you only want to support Math, could have "evaluateDoube(), evaluateBool(), or have generics similar to Optional, etc.),
cannot configure exclude native functions or operators if you don't want to support them
APIs also could be improved. for example all operations have either 1 or 2 arguments, so instead of double...varargs it could be Operator.appy(Double left, Double right) with "left" being null for things like negative number, and "right" be null for factors ie. 4!. Also instead of custom Operator class it could actually use Java's default BiFunction, and similar improvements
many many many unnecessary validations:
only certain symbols can be used for operators, why forbid using any "string" as operator? ie. "X div Y"
variables must have a specific format (start/end/etc), why can't I have all my variables start with % ?
variable and function names must be different (here a custom prefix functionality would help)
and many many more..
My use-case was / I though that I will be able to create with this library something to evaluate custom expressions like "$distance(%d1, %d2) >= 10 && $size(%myarray) < %var3" and I could create custom Functions for $Distance(Number, Number) and $Size(Collection), Operators for "<", ">=" (less, more or equals returning boolean), "&&" (boolean comparator returning boolean) that in the end could evaluate to Boolean. Ability to disable implicit functions like sin, cos, etc. would be a bonus.
However it was impossible, because of validations and limitation to "only use doubles". The saddest part is that the main backbone code of this library could do so much more (everything I wanted to do above). Perhaps I will fork it or just copy the useful parts to my code and refactor to support what I need.
The text was updated successfully, but these errors were encountered:
When I saw this library and that it supports custom operators and functions I very much wanted to include it in my project as an expression evaluator, but sadly could because it is very (unnecessarily) limited for only math. Mainly because:
My use-case was / I though that I will be able to create with this library something to evaluate custom expressions like "$distance(%d1, %d2) >= 10 && $size(%myarray) < %var3" and I could create custom Functions for $Distance(Number, Number) and $Size(Collection), Operators for "<", ">=" (less, more or equals returning boolean), "&&" (boolean comparator returning boolean) that in the end could evaluate to Boolean. Ability to disable implicit functions like sin, cos, etc. would be a bonus.
However it was impossible, because of validations and limitation to "only use doubles". The saddest part is that the main backbone code of this library could do so much more (everything I wanted to do above). Perhaps I will fork it or just copy the useful parts to my code and refactor to support what I need.
The text was updated successfully, but these errors were encountered: