Control flow and compact declarations
f sum(a: *i32, n: i32) i32
total := 0
for i := 0; i < n; i++
if a[i] < 0
^
elif a[i] == 0
!
else
total += a[i]
while total > 10
total--
< totalint sum(int *a, int n) {
int total = 0;
for (int i = 0; i < n; i++) {
if (a[i] < 0) {
continue;
} else if (a[i] == 0) {
break;
} else {
total += a[i];
}
}
while (total > 10) {
total--;
}
return total;
}| Syntax | C translation |
|---|---|
f name T / f name(args) T | Function with optional return type |
int x,y,z | Shared C parameter type |
| final value expression | Implicit return in non-void functions |
s Name / u Name / e Name | Struct / union / enum with a typedef |
name := literal | Declaration with literal-derived C type |
name: CType = expression | Explicit C declaration |
< expression / < | Early value return / void return |
if condition / elif condition / else | if / else if / else |
while condition | while |
for init; condition; step | for |
! / ^ | break / continue |
+stdio,stdlib / +<header.h>,"local.h" | Multiple C includes; bare names add .h |
Indentation uses spaces. A body must be deeper than its header, siblings align, and dedents must match an enclosing level. Canonical formatting uses two spaces. Missing, empty or inconsistently indented bodies are rejected. Runtime branches match an if at the same indentation. Block colons and inline then spellings are not part of v1. C expressions retain C operator spelling, precedence and evaluation rules: !x, !!x, ~x, a^b, a?b:c and x=y are expressions. Only a standalone ! or ^ is a loop-control statement; !x and a^b remain C expressions. Outer parentheses around control headers are rejected.