Renderingen-US

Experimental through version 1. Version 0 was alpha. This is the first language release: the interface is relatively stable, not frozen. Nothing is promised stable until version 2.

Statements & control flow

Keyword spelling

A statement is a step the program takes. This family is how control moves: if / elif / else choose a branch, while repeats while a condition holds, for walks a collection or a range, switch selects an arm by value, and match exhausts the variants of a union.

then lets a branch be a single statement instead of a block — a common way to write an early return. guard groups those checks at the top of a function. return leaves a function; break and continue leave or skip a loop; pass is the explicit empty body. assert and panic are diagnostics. require and reject are the one-line throws; they need an error channel, which lives on the error channel page.

main {
    let i32 score ← 85
    if score ≥ 90 {
        print "A"
    }
    elif score ≥ 80 {
        print "B"
    }
    else {
        print "C"
    }
    let list<i32> nums ← [1, 2, 3]
    for from nums let item {
        print item
    }
    mut i32 n ← 0
    while n ≺ 2 {
        n ← n + 1
    }
    print n
}

switch picks the first matching value. default is the fallback:

fn describe(i32 value) → string {
    switch value {
        case 1 { return "one" }
        case 2 { return "two" }
        default { return "many" }
    }
}

main {
    print describe(2)
}

Return to the grammar overview.

Terms#

These are the words you write in this part of the language. Each links to its page. The second column names the grammar rule the word belongs to.

TermGrammar rule
ifsi_stmt
elifsi_tail
elsesecus_clause
whiledum_stmt
ref, for, let, mutitera_stmt
range, and, fromitera_clause
anditera_binding
atapud_clause
switchelige_stmt
casecasu_elige_clause
defaultceterum_clause
match, alldiscerne_stmt
anddiscriminants
casecasu_variant_clause
guardcustodi_stmt
ifsi_guard_clause
from, let, mutex_stmt
asextract_field
restceteri_field
returnredde_stmt
return_awaitreddet_stmt
awaittacebit_stmt
yieldcede_stmt
breakrumpe_stmt
continueperge_stmt
passtacet_stmt
assert, panicadfirma_stmt
throw, requirerequirit_stmt
throw, rejectreice_stmt
warn, write, debugnota_stmt
while, dofac_stmt
allfac_modifier

Formal grammar#

The rules for this part of the language are the parser's own definition of it. They are written for models and tools, so this page does not repeat them; the full list is at every production.