if/else, match, return, and two local bindings (let and var). Loops are reserved but not executable in v0.1.
Local bindings
let
Immutable local binding. Cannot be reassigned.
var
Mutable local binding. Requires an explicit type.
letsupports type inference when the initializer type is obvious.- Local
varrequires an explicit type in v0.1. letbindings cannot be reassigned; immutable members follow the same rule.
if / else
if branches on a Bool. There are no truthy or falsy coercions.
else if:
if customer will not compile. Kairo forces you to write the check you actually mean, like if customer != null.match
match branches on a pattern. It has two forms: statement and expression.
Statement match
Uses block arms. Good when each arm does side-effecting work.Expression match
Uses arrow arms and returns a value. Must be exhaustive with anelse arm in v0.1.
- Literal values (
0,"paid",true) - Enum cases (
Draft,Paid) null- Type names
else
return
return exits the current callable, optionally with a value.
Loops (reserved)
for and while are reserved keywords in v0.1. Their executable semantics are deferred until the next ratified stage.
Combining with Result
match on result.isSuccess is the standard pattern for handling Result<T, E>:
Next steps
Error handling
Result<T, E> and faults.Operators reference
Boolean, equality, comparison, and arithmetic operators.
