dum
Translation status: العربية reader-locale proof. Code fences render through the ar pipeline; prose is canonical Latin.
Repeats a block while a condition remains true.
Aliases: while
Syntax: dum <condition> <block|ergo statement>
Category#
control-flow
Related#
Examples#
radix/corpus/dum/dum.fab (canonical · keyword)#
Repeats a block while a condition remains true.
# =============================================================================
# dum — Repeats a block while a condition remains true.
# =============================================================================
#
# What this teaches:
# • While loop — `dum <condition> { <body> }` repeats a block as long as the condition is true.
# • Loop variable mutation — mutable `varia` bindings allow counter-based loop control.
# • Ascending and descending loops — counting up from 0 or down from N until the condition is falsum.
#
# Common mistakes:
# • Using `rumpe` or `perge` outside a loop — both are only valid inside `dum`, `itera`, `fac`, `meus`, or `tuus` blocks (SEM030, SEM031).
#
# See also: si, ergo, fac
# =============================================================================
# dum — while loop
#
# dum <condition> { <body> }
#
# GRAMMAR:
# loopStmt :← 'dum' expr '{' stmt* '}'
#
# EXPECTED OUTPUT:
# dum.expected
main {
# Ascending counter: varia so the loop variable can mutate
var int computus ← 0
while computus < 5 {
print computus
computus ← computus + 1
}
# Descending loop: condition becomes falsum at 0
var int reliquum ← 3
while reliquum > 0 {
print "reliquum: §"(reliquum)
reliquum ← reliquum - 1
}
print "perfectum!"
}
test "dum counts up to its condition" {
var int computus ← 0
while computus < 5 {
computus ← computus + 1
}
assert computus ≡ 5
}
test "dum counts down to zero" {
var int reliquum ← 3
while reliquum > 0 {
reliquum ← reliquum - 1
}
assert reliquum ≡ 0
}Expected output:
0
1
2
3
4
reliquum: 3
reliquum: 2
reliquum: 1
perfectum!