Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Keywords Reference

Restrict reserves a compact set of words for current syntax and future design space. This page separates the implemented v0.0.1 surface from words that remain reserved for future work.

Current Declaration Keywords

KeywordUse
funDefine a function.
valDefine an immutable binding.
mutMark a binding mutable as mut val.
recordDefine a record type.
enumDefine a closed, non-generic, non-recursive user enum.
formDefine a non-generic, method-only static interface.
takesAdopt a form for one concrete, non-generic record.
ofRequire one or more forms on a generic type parameter.
contextDefine a context binding shape.
pubExpose a supported top-level declaration from a source module.
importImport from dotted source modules.
exportExpose a host-visible function or supported scalar constant.
implDefine type-directed functions for a receiver type.
asReserved for import/type naming positions; aliases are outside v0.0.1 source imports.

Examples:

record Score {
    value: Int32
}

fun bump: (score: Int32) -> Int32 = {
    score + 1
}

export fun exported_score: () -> Int32 = {
    41 |> bump
}

User enum variants have zero or one payload and stay qualified under the enum name:

pub enum ParseError {
    Empty
    Message(String)
}

fun make_error: (message: String) -> ParseError = {
    message |> ParseError::Message
}

pub enum exposes the type to Restrict source modules only; it does not define a host enum ABI. Generic or recursive enums and ? propagation remain future work.

Forms use fully typed method signatures, while adoptions provide their bodies:

pub form Labelled {
    fun label: (self: Self) -> String
}

record Badge {
    text: String
}

Badge takes Labelled {
    fun label: (self: Badge) -> String = {
        self.text
    }
}

fun read_label: <T of Labelled>(value: T) -> String = {
    value |> label
}

The compiler selects these calls statically. Generic forms, associated types, default methods, conditional or generic adoptions, enum adoptions, and dynamic dispatch remain outside the current slice.

Mutable bindings place mut before val:

fun next_counter: () -> Int32 = {
    mut val counter = 0;
    counter = counter + 1;
    counter
}

Current Expression Keywords

KeywordUse
thenIntroduce the true branch of a conditional expression.
elseIntroduce the false branch.
matchPattern-match the value on its left.
trueBoolean true literal.
falseBoolean false literal.
SomeBuilt-in Option<T> present constructor.
NoneBuilt-in Option<T> absent match pattern; construct with () Option::None.
withBind a context value for a block.
fun label: (score: Int32) -> String = {
    score >= 80 then {
        "pass"
    } else {
        "retry"
    }
}

fun option_score: (value: Option<Int32>) -> Int32 = {
    value match {
        Some(score) => { score }
        None => { 0 }
    }
}

Result::Ok and Result::Err are qualified built-in Result<T, E> constructors. The unqualified names remain match patterns; value construction uses the qualified namespace:

fun checked_score: (score: Int32) -> Result<Int32, String> = {
    score >= 0 then {
        score Result::Ok
    } else {
        "negative" Result::Err
    }
}

Prototype And Ownership Keywords

KeywordUse
cloneRecord clone/update operation as .clone { ... }.
freezeCreate an immutable prototype-style value.
fatalReserved for fatal diagnostics and termination-oriented design.
record Reading {
    value: Int32,
    valid: Boolean
}

fun mark_valid: (reading: Reading) -> Reading = {
    reading.clone { valid: true }
}

Reserved Or Experimental

Keywordv0.0.1 status
temporalReserved for Temporal Affine Types, outside the default gate.
withinReserved for temporal/lifetime syntax.
whereReserved for future type constraints.
lifetimeReserved for lifetime syntax.
awaitReserved for async design.
spawnReserved for concurrency design.

Do not use reserved words as identifiers. If documentation or examples need a feature from this table, mark it as future or experimental instead of presenting it as current syntax.