Releases: expr-lang/expr
v1.12.7
Expr is a Go package that offers a fast, simple, and safe engine for compiling and evaluating expressions. Ideal for implementing complex logic in configuration, it serves as a foundation for a dynamic business rule engine without the need for recompiling the program.
- Added new opcode
OpInvalid
for debugging purposes.
v1.12.6
What's Changed
- Churn: remove duplicate codes by @Schneizelw in #356
- Fix: fixed a compilation error. by @PranavPeshwe in #355
- Doc: update Visitor-and-Patch.md by @mdmcconnell in #369
- Feature: env[] keyword implemented in parser by @mdmcconnell in #382
New Contributors
- @Schneizelw made their first contribution in #356
- @PranavPeshwe made their first contribution in #355
- @mdmcconnell made their first contribution in #369
Full Changelog: v1.12.5...v1.12.6
v1.12.5
v1.12.4
v1.12.3
v1.12.2
v1.12.1
v1.12.0
v1.11.1
v1.11.0
Expr – an expression language for Go.
This release introduces a new API for defining functions inside Expr - expr.Function.
From an Expr expression is already possible to call any Go methods and functions, but Expr has to use reflect package in doing such calls.
In previous releases, Expr added a special case for func (...any) any
to avoid using reflect. But such functions lack type information. With newly added expr.Function option now it's possible to define a fast function with optional types! Read more in the docs.
atoi := expr.Function(
"atoi",
func(params ...any) (any, error) {
return strconv.Atoi(params[0].(string))
},
new(func(string) int),
)
program, err := expr.Compile(`atoi("42")`, atoi)
Also in this release:
- Added bool condition optimization.
- Added support for comments
//
and/* ... */
. - Added support for negative indexes
list[-1]
. - Predicate brackets are now optional
all(list, .values > 0)
. - Added
int()
andfloat()
builtins. - Improved built-in functions performance.