This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
Eval
~import std/evalExpression Evaluator Standard Library
eval.kz · 2 tors · ~[runtime]
Expression Evaluator Standard Library · 22 more lines
Expression Evaluator Standard Library
Runtime evaluation of Koru/Zig expressions
DESIGN:
- Expressions are parsed at parse-time (not strings!)
- Evaluation happens at runtime against a binding environment
- Supports literals, bindings, field access, comparisons, boolean ops
- Matches Zig expression syntax for parity
Usage:
import std/eval
std/eval:eval(expression: score > 50, bindings: env)
| bool b |> if(b) ...
| int n |> ...
| string s |> ...
| error e |> ...
// Or inline in conditionals:
std/eval:eval-bool(expression: user.role == "admin", bindings: env)
| true |> ...
| false |> ...
eval
koru_std/eval.kz:411// PUBLIC API - Koru events
//
// Evaluate an expression and return its value
~pub tor eval { expression: Expression, bindings: *const Bindings }
| bool bool
| int i64
| float f64
| string string
| null
| error stringeval-bool
koru_std/eval.kz:437// Test an expression for truthiness (convenience for conditionals)
~pub tor eval-bool { expression: Expression, bindings: *const Bindings }
| true
| false
| error string