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.

Patterns & destructuring

Keyword spelling

A pattern is what a match arm accepts. It is not the match statement itself — that lives with statements — it is the shape on the left of each case: a literal, a type, a binding, or a destructured object or array.

and joins patterns that must all hold; or offers alternatives. let / mut / as bind a name to what matched. rest keeps the leftover fields or elements. The same atoms appear when a union-typed value is read back out by member type.

main {
    let i32 ∪ string signum ← 7

    match signum {
        case i32 let n { print "a number" }
        case string let s { print "a text" }
    }
}

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
andpatterns
orpattern
let, as, mutut_pattern
aspattern_binding
rest, aspattern_property
restarray_pattern_element

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.