a fork of EvalEx by ezylang with a handful of breaking changes
at main 114 lines 4.7 kB view raw view rendered
1--- 2layout: default 3title: Major Changes 4parent: Concepts 5nav_order: 5 6--- 7 8## Major Changes From Version 2 to 3 9 10### New features 11 12There are a lot of new features, see the [home page](../index.html) of this 13documentation for more information. 14 15Most notably new features: 16 17* Better boolean support. 18* Support for string operations and functions. 19* Support for date-time and duration values and operations. 20* Support for _null_ values. 21* Support for multidimensional arrays. 22* Support for nestable structures. 23* Structures and arrays can be combined to work with arbitrary data structures. 24* New data access support, connecting expressions with you data made easy. 25* New configuration concept. 26 27### License 28 29The license has changed from MIT to Apache 2.0. This should not be a problem, as both licenses are 30very similar. The Apache 2.0 license though is clearer about certain constraints to some use cases. 31 32### New Java version 33 34EvalEx 3 now requires at least Java 11 to run and compile. 35 36### New package, group id and repository home. 37 38EvalEx has moved from a personal repository to an organizational repository. 39This decouples the product from a single person and allows more and better control over the product. 40 41### Complete rewrite 42 43EvalEx 3 is a complete rewrite. After 10 years of adding features and trying to stay backward 44compatible, I felt that this is the time for a big cut. 45Trying to stay backward compatible has introduced several code constructs, that didn't feel good. 46 47This cut has direct impact to the integration of EvalEx in an existing application. 48Though I believe that the new version has much better integration possibilities (e.g. the data 49access interface, the separate configuration object), existing integrations need some refactorings. 50 51Depending on how you used EvalEx until now, this may not need very much changes, e.g.: 52 53* Change the dependency coordinates of EvalEx to the new group id. 54* Change the package imports. 55* Adopt the new method and class names. 56* Use the new return value (EvaluationValue instead of BigDecimal). 57 58When you were using custom functions or operators, or own configurations, then you may need a bit 59more work. Though even these migrations are straight forward and pretty easy. 60 61Here are the main changes, when it comes to integration: 62 63### New configuration concept 64 65Configurations are now separated from the expression. You can create a configuration once and then 66re-use it with your expressions. All the heavy constructor work is now in the configuration, making 67the instantiation of an expression much faster. 68 69### New default MathContext 70 71The new default MathContext has a precision of 68 with a HALF_EVEN rounding mode, compared to a 72precision of 7 in EvalEx 2. This is a major leap forward. Low precision has been a constant issue 73with EvalEx 2. 74 75### Moved from RPN to AST 76 77EvalEx 2 used RPN (Reverse Polish Notation) for evaluation. The parser transformed the infix 78notation to an RPN notation and used this representation for evaluation. 79 80Now the parser transforms the infix notation to an AST (Abstract Syntax Tree), allowing several 81improvements and new features. The main reason for the switch was the lazy evaluation needed for the 82IF function. With the use of an AST, this was easy to achieve. 83 84If you were using the getRPN() function in EvalEx 2, then the new getAllASTNodes() or 85getAbstractSyntaxTree() methods may be useful for you. 86If you still need RPN support, it should be possible to create an RPN notation out of the AST with a 87bit of effort. 88 89### New return value type 90 91EvalEx 2 evaluation always returned a BigDecimal. With the new support of strings, arrays and 92structures, this was not suitable anymore. The new EvaluationValue return type for an evaluation has 93a type member that defines what data type it holds (boolean, number, string, array, structure, or an 94AST). It also has some convenience methods to convert the values, e.g. number to string. 95 96### New data access concept 97 98EvalEx 2 had an own storage for variable and constant values, that had to be filled with the 99required values before evaluation. This is also the default with EvalEx 3, so no change to 100existing integrations is required. 101 102But the new concept allows additionally to configure a custom data access interface, which could be 103backed by any kind of storage. 104See chapter [Data Access](../customization/data_access.html) for details. 105 106### Custom Operators 107 108Adding custom operators is now easier, but has changed significantly. 109See chapter [Custom Operators](../customization/custom_operators.html) for details. 110 111### Custom functions 112 113Adding custom functions is now easier, but has changed significantly. 114See chapter [Custom Functions](../customization/custom_functions.html) for details.