Statements
Statements perform actions. Unlike expressions, they don't produce values.
Variable Declarations
let
Declare an immutable variable:
lumen
let x = 42
let name = "Alice"
let pair = (1, 2)let mut
Declare a mutable variable:
lumen
let mut counter = 0
counter = counter + 1
counter += 1Type Annotations
lumen
let count: Int = 10
let message: String = "hello"
let items: list[Int] = [1, 2, 3]Destructuring
lumen
let (a, b) = (1, 2) # Tuple
let [first, second] = [1, 2] # List
let Point(x, y) = point # RecordAssignments
lumen
x = 42
user.name = "Alice"
items[0] = 100Compound Assignment
lumen
x += 1 # x = x + 1
x -= 1 # x = x - 1
x *= 2 # x = x * 2
x /= 2 # x = x / 2
x //= 2 # x = floor(x / 2)
x %= 2
x **= 2
x &= 0xFF
x |= 0x01
x ^= 0x10Conditionals
if
lumen
if x > 0
print("positive")
endif-else
lumen
if x > 0
print("positive")
else
print("not positive")
endif-else if-else
lumen
if score >= 90
grade = "A"
else if score >= 80
grade = "B"
else if score >= 70
grade = "C"
else
grade = "F"
endif let
lumen
if let Some(value) = maybe
print(value)
endLoops
for
lumen
for item in items
print(item)
endLabeled for-loop:
lumen
for @outer item in items
if item == "skip-all"
continue @outer
end
endWith index:
lumen
for (index, item) in enumerate(items)
print("{index}: {item}")
endWith filter:
lumen
for x in numbers if x > 0
print(x)
endwhile
lumen
while count < 10
print(count)
count += 1
endLabeled while-loop:
lumen
while @retry should_continue()
if done()
break @retry
end
endwhile let
lumen
while let Some(item) = next()
process(item)
endloop
lumen
loop
let input = read()
if input == "quit"
break
end
process(input)
endLabeled loop:
lumen
loop @main
if should_stop()
break @main
end
endbreak
Exit a loop:
lumen
for x in items
if x == target
break
end
endTarget a label in nested loops:
lumen
break @outerWith value (for loop expressions):
lumen
let found = for x in items
if x == target
break x
end
endcontinue
Skip to next iteration:
lumen
for x in items
if x % 2 == 0
continue
end
print(x)
endTarget a label:
lumen
continue @outerdefer
defer schedules statements to run when the current scope exits.
lumen
cell run() -> Int
defer
print("cleanup")
end
print("work")
return 1
endMatch
lumen
match value
0 -> print("zero")
1 -> print("one")
_ -> print("many")
endWith guards:
lumen
match n
x if x < 0 -> print("negative")
x if x == 0 -> print("zero")
_ -> print("positive")
endWith bindings:
lumen
match result
ok(value) -> print(value)
err(msg) -> print("Error: {msg}")
endreturn
Return from a cell:
lumen
cell add(a: Int, b: Int) -> Int
return a + b
endEarly return:
lumen
cell find(items: list[Int], target: Int) -> Int | Null
for item in items
if item == target
return item
end
end
return null
endhalt
Stop the entire program:
lumen
cell main() -> Null
let config = load_config()
if config == null
halt("Configuration required")
end
run()
return null
endemit
Emit a trace event:
lumen
cell process(data: String) -> String / {emit}
emit("Processing: {data}")
return transform(data)
endExpression Statements
Expressions can be statements when their result is ignored:
lumen
print("hello") # Function call as statement
items.append(1) # Method call as statement
spawn(background()) # Spawn as statementStatement Blocks
Groups of statements:
lumen
cell example() -> Int
let a = 1
let b = 2
if a > 0
let c = a + b
return c
end
return 0
endControl Flow Summary
| Statement | Purpose |
|---|---|
if / else | Conditional execution |
for | Iterate over collections |
while | Loop while condition is true |
loop | Infinite loop (use with break) |
match | Pattern-based branching |
return | Exit function with value |
break | Exit loop |
continue | Skip to next iteration |
defer | Run cleanup code on scope exit |
halt | Stop program |
Next Steps
- Pattern Matching — Detailed pattern reference
- Declarations — Top-level declarations