Language Guide Overview
Welcome to the Restrict Language guide. These pages describe the current v0.0.1 release-facing syntax, including its closed enum and static form slices, and mark future boundaries where they matter.
What You’ll Learn
- OSV Word Order - Calls put arguments before functions
- Syntax Reference - Current declarations, expressions, and literals
- Type System - Built-ins, closed user enums, generics, and affine ownership
- Functions - Function declarations, values, and OSV calls
- Higher-Order Functions and Collection Transforms -
map,filter,fold, and scoped callbacks - Forms and Static Polymorphism - Method-only forms, concrete adoptions, and
ofbounds - Ownership - Memory management without GC
- Pattern Matching - Exhaustive
matchexpressions - Warder Package Manager - Managing dependencies
Quick Example
record ReleaseSignal {
score: Int32,
passing: Boolean
}
fun summarize_release: (signal: ReleaseSignal) -> String = {
signal match {
ReleaseSignal { passing: true, score } => {
"ready"
}
ReleaseSignal { passing: false, ..._ } => {
"blocked"
}
}
}
fun main: () -> String = {
val signal = ReleaseSignal { score: 92, passing: true };
signal |> summarize_release
}
Key Concepts
OSV Syntax
Restrict uses Object-Subject-Verb call order. Arguments come first:
value |> function, (left, right) function, and () function.
Affine Types
Heap-backed values such as strings, lists, records, and function values are
affine by default. Copyable primitives such as Int32, Boolean, Float64,
Char, and () can be reused.
Type-Directed Impl Functions
impl blocks define functions selected by the receiver type, but calls remain
OSV. Use (receiver, args...) function_name, not object-style method calls.
Static Forms
Method-only forms express reusable requirements. Concrete records adopt a form
with takes, and generic functions list bounds with <T of Form>. The compiler
selects and monomorphizes every method call without runtime form objects.
Pattern Matching
match is also OSV: the value being matched appears before the match
keyword, and each branch body is wrapped in braces. Closed user enums use
qualified Type::Variant patterns and must be matched exhaustively.
Zero GC
Restrict targets deterministic memory management through compile-time checks and WASM-friendly data layouts.