07-control (pocket version)
TL;DR (5 lines)
- Control flow is about path ownership.
- A single scenario teaches branches better than isolated snippets.
- Each branch should change an observable outcome or invariant.
- Invalid control examples should isolate structural mistakes.
- Read the path first, the tokens second.
Concrete Problem
Control-flow chapters become repetitive when they explain keywords separately without one scenario showing how branches cooperate.
Coherent example
space demo/control
proc sum_positive(values: list[int]) -> int {
let acc: int = 0
for value in values {
if value < 0 { continue }
set acc = acc + value
}
give acc
}
Global explanation
Control flow must be taught as a route through the program, not as isolated keywords. The reader should see where the path changes, why it changes, and how the result remains understandable.
Short exercise
Add one fallback branch to the example and explain what new path it creates.
Next best action
Keep the example small, reproduce it locally, then continue to the full chapter if you need the broader context.