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/sit/sit.fab (canonical · keyword)#
Declares an inferred immutable local.
# =============================================================================
# let — Declares an inferred immutable local.
# =============================================================================
#
# What this teaches:
# • Immutable binding sugar — `let name` is a compact alternative to
# `const _ name` for inferred-type immutable locals
# • Supports immediate init (`let x ← expr`) and deferred init
# (`let x` then `x ← expr` later)
#
# Common mistakes:
# • Confusing `let` (sugar for `const _`) with `var` — `let` creates an immutable binding.
#
# See also: const, var, ←
# =============================================================================
# let — inferred immutable bindings
#
# Immediate init:
# let name ← expr -- compact sugar for const _ name ← expr
#
# Deferred init:
# let name -- compact sugar for const _ name (assign once later)
# name ← expr
#
# Prefer let when a block chains several inferred locals; keep const _ when
# teaching the explicit infer marker or mixing typed and inferred bindings.
#
# 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
const _ idem ← nuntius
print idem
}Expected output:
Salve, Marcus!
deferred
Salve, Marcus!