Atoll’s control-flow forms are expressions. if, match, and value-bearing
loops can be assigned, returned, or nested wherever their result type is
accepted.
| Chapter | Main question |
|---|---|
| Blocks | How do statement sequences create scopes and values? |
| Conditionals | How do if, else if, and else join branch types? |
| Loops | How do condition, infinite, iterator, and range loops work? |
| Patterns | Which values can bindings and match arms destructure? |
| Match | How are alternatives selected, guarded, typed, and checked for coverage? |
| Defer | How is deterministic scope cleanup registered and ordered? |
Value flow
label := if count == 0 {
"empty"
} else {
"ready"
}
result := match next_item() {
Some(item) if item.enabled => item.value,
Some(_) => 0,
None => -1,
}Each branch contributes to the expression’s type. If a branch transfers control
with return, break, continue, or error, its never type does not force
the other branches to change their value type.
Loop choices
Use for item in iterable for collections and streams, for index in start..end
for integer ranges, for condition for a condition-controlled loop, and bare
for for an infinite loop. A loop can yield a value through break value when
all reachable exits agree on a type.
Patterns connect loops, bindings, and matches. Learn them before relying on exhaustive enum handling or destructuring nested values.
return, break, and continue transfer control explicitly. There is no
ternary operator, switch, or goto. The current language uses for for all
loop shapes; legacy while and loop tokens are retained only for migration
diagnostics and compatibility paths.
defer is lexical cleanup, not a general event handler. Deferred work runs
when its scope leaves normally or by transfer, including error propagation and
cancellation cleanup. Read it after blocks and before resource-heavy standard
library or transaction code.