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.

Declarations & bindings

Keyword spelling

A declaration introduces a name the rest of the file can use. Four binding words say how a name is bound: let is a fixed name, mut is re-pointable and writable, ref is re-pointable and read-only, and const T X = e is a compile-time fact. Every one writes its type slot, and _ asks for inference. Functions, closures, and classes are declarations too — they name a callable or a type, and the fields and methods it holds.

The type always comes before the name: i32 count, never count: i32. ← stores a value at run time. = is for a field's shape inside a literal, not for binding a local. Generic parameters (<T>), implements bounds, and the modifiers on a function (async, throws, args) belong here because they are part of how the name is declared.

A function and two bindings:

fn divide(i32 a, i32 b) → i32 ∪ none {
    if b ≡ 0 then return null
    return a / b
}

main {
    let i32 seven ← 7
    mut i32 n ← 3
    n ← n + 1
    print divide(seven, n)
}

A class names its fields the same way. Methods are functions on the class; self is the instance:

class Span {
    let f64 low
    let f64 high

    fn contains(f64 x) → bool {
        return self.low ≤ x and x ≤ self.high
    }
}

main {
    let Span bytes ← Span { low = 0.0, high = 255.0 }
    print bytes.contains(128.0)
}

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
embedinsere_expr
const, const, mutfixum_decl
await_const, await_varfigendum_decl
let, letsit_decl
refref_decl
let, mutarray_destruct
let, mutobject_destruct
fnfunctio_decl
kernelkernel_decl
implementsgeneric_bound
rest, optional, as, coalesceparameter
args, errors, exit, throws, readonly, optionsfunc_modifier
async_generator, async, generatorcallable_posture
thenergo_joint
dofac_block
lambdaclausura_legacy_expr
class, implementsgenus_decl
fnnondum_method_decl
let, optional, mutgenus_field_decl
constgenus_const_decl
let, optional, mutfield_decl
fnfunctio_method_decl

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.