let
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Declares an inferred immutable local.
Syntax: let <name> [← <expression>]
Category#
binding
Related#
Examples#
radix/corpus/reference/keyword/sit/sit.fab (canonical · keyword)#
Declares an inferred immutable local.
# =============================================================================
# let — Declares an inferred immutable local.
# =============================================================================
#
# What this teaches:
# • Write-once binding — `let name` declares an inferred-type local that
# is written once
# • Supports immediate init (`let _ x ← expr`) and deferred init
# (`let x` then `x ← expr` later)
#
# Common mistakes:
# • Confusing `let` with `mut` — `let` creates a write-once binding.
#
# See also: const, mut, ←
# =============================================================================
# let — inferred immutable bindings
#
# Immediate init:
# let _ name ← expr -- inferred write-once local
#
# Deferred init:
# let name -- deferred: assign once later
# name ← expr
#
# `let` infers the type; write `let T name ← expr` to state it. `const` is for
# compile-time constants only.
#
# GRAMMAR:
# sitDecl := 'let' IDENTIFIER ('←' expression)?
#
# EXPECTED OUTPUT:
# sit.expected
main {
let _ salve ← "Salve"
let _ name ← "Marcus"
let _ nuntius ← "§, §!"(salve, name)
print nuntius
let _ label
label ← "deferred"
print label
let _ idem ← nuntius
print idem
}Expected output:
Salve, Marcus!
deferred
Salve, Marcus!