varia
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Declares a mutable binding.
Aliases: let, mutable
Syntax: mut <type|_> <pattern> [← <expression>]
Category#
binding
Related#
Examples#
radix/corpus/varia/varia.fab (canonical · keyword)#
Declares a mutable binding.
# =============================================================================
# mut — Declares a mutable binding.
# =============================================================================
#
# What this teaches:
# • Mutable bindings — `mut` for values that can be reassigned after declaration
# • Write-once bindings — `let` for values that cannot be reassigned
#
# Common mistakes:
# • declaring mut when the binding is never reassigned — use let instead (WARN013)
#
# See also: const, ←, ↑
# =============================================================================
# Mutable and immutable variable declarations
#
# mut <name> ← <expr> -- mutable binding (may reassign)
# let <name> ← <expr> -- write-once binding (see let/sit.fab)
#
# GRAMMAR:
# bindingStmt :← ('mut' | 'let') type? ident '←' expr
#
# EXPECTED OUTPUT:
# 0, 1, 11, "Salve, Mundus!", 30, "Vale"
main {
# --- Mutable bindings with mut ---
mut _ computus ← 0
print computus
computus ← 1
print computus
computus ← computus + 10
print computus
# --- Write-once bindings: let ---
let _ salutatio ← "Salve, Mundus!"
print salutatio
# let infers the type of each local
let _ x ← 10
let _ y ← 20
let _ sum ← x + y
print sum
# --- Reassign only mut bindings ---
mut _ nuntius ← "Salve"
nuntius ← "Vale"
print nuntius
}Expected output:
0
1
11
Salve, Mundus!
30
Vale