Tasks and functions
Declare typed parameters, return results and test a task.
A task declares its parameters in parentheses. gives declares a result type and give returns a value. Tasks without a result type use unit. Type-checking resolves task calls before execution.
Test tasks use the test_ naming convention and are executed with zebvix test. Built-ins include len, text, append, put and assert. Standard-library functions include text_upper and text_split, math_abs and math_min, parse_i64, UTF-8 encoding and decoding, and JSON string escaping. File functions need both a source declaration and explicit host grants.
easy
examples/easy/src/main.zbl · v0.5.0-preview.5 · interpreter, bytecode
needs console
name = "Zebvix"
task welcome(user: text):
show "Welcome " + user
welcome(name)
total = 0
repeat value in [10, 20, 30]:
total = total + value
show total
task test_total():
assert(1 + 2 * 3 == 7)
Welcome Zebvix
60