Expr is a Go-centric expression language designed to deliver dynamic configurations with unparalleled accuracy,
safety, and speed.
program, err := expr.Compile(`let foo = bar(); baz(foo, foo)`)
In this release:
This release added the biggest change to the Expr language: if-else expressions and sequential expressions. #736 e750878
if foo > 42 {
assert(foo);
calc(foo, foo / 2)
} else {
calc(0, 0)
}
A sequence of expression may be separated by ;
char. The last semicolon must be omitted. Expr returns the value of the
last expression in the sequence.
If-else is also expressions. Each if
must have an else
part. Result of if-else can be used as an expression:
let foo = if bar > 0 {
process(bar)
} else {
fallback()
};
foo + 42
Added:
- Added
ast.Find
helper for easy AST searching. 579de74 - Added compile node budget and memory limits (#762)
- Added
uniq()
builtin (#705) - Added
flatten()
builtin (#684) - Added types pkg (#665 #667 #668)
Improvements:
- Allow tailing comma in arguments (#623)
- Improved type checker for named types 6fa83ad
- Now
len()
return runes count for string e8bd7f8 - Improved VM code coverage (now 98%!) (#750)
- Improved support for auto-dereferences and pointer usage 2bc0eed f4bbea5 80f0ea6 4511e92 29dff34
Fixes:
- Make sure
get()
returns nil formap[string]string
on missing keys 435b79d - Fixed func calls with nil types value d63c3b5
- Fixed AST printing of ops with precedence (#678)
- Do not optimize
filter() | map()
if#index
is used 35bdb68 - Separated patching phases for patchers that require multiple passes. (#659)