Skip to content

Releases: expr-lang/expr

v1.12.7

19 Jul 13:26
d2100ec
Compare
Choose a tag to compare

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

12 Jul 09:03
3c23d10
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.12.5...v1.12.6

v1.12.5

21 Mar 11:08
Compare
Choose a tag to compare

fb81647 Fixed param type overwriting in type propagation logic
b3fb3b9 Added a more beautiful program disassemble output

v1.12.4

20 Mar 20:22
Compare
Choose a tag to compare
  • Fixed method calls on interfaces 1a1138d

v1.12.3

10 Mar 21:32
e10a35d
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.12.2...v1.12.3

v1.12.2

09 Mar 12:51
5613693
Compare
Choose a tag to compare
  • Fixed runtime.Fetch for named slices by @blotus in #349

New Contributors

Full Changelog: v1.12.1...v1.12.2

v1.12.1

22 Feb 22:58
Compare
Choose a tag to compare
  • Fixed a bug with builtins and nil argument.

v1.12.0

03 Feb 14:56
Compare
Choose a tag to compare
  • Added nil coalescing operator ??.

Example:

user?.Name ?? "Anonymous"

v1.11.1

03 Feb 10:07
Compare
Choose a tag to compare
  • Fixed abs() for positive numbers

v1.11.0

02 Feb 08:41
Compare
Choose a tag to compare

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() and float() builtins.
  • Improved built-in functions performance.