fasseg / exp4j

A tiny math expression evaluator for the Java programming language
http://www.objecthunter.net/exp4j/
Apache License 2.0
475 stars 160 forks source link

Missing features (or too many restrictions) for general purpose expression evaluator #114

Open cr3ativ3 opened 3 years ago

cr3ativ3 commented 3 years ago

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.