đặt
Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.
Declares an inferred immutable local.
Syntax: đặt <name> [← <expression>]
Category#
binding
Related#
Examples#
radix/corpus/sit/sit.fab (canonical · keyword)#
Declares an inferred immutable local.
# =============================================================================
# đặt — Declares an inferred immutable local.
# =============================================================================
#
# What this teaches:
# • Immutable binding sugar — `đặt name` is a compact alternative to
# `hằng _ name` for inferred-type immutable locals
# • Supports immediate init (`đặt x ← expr`) and deferred init
# (`đặt x` then `x ← expr` later)
#
# Common mistakes:
# • Confusing `đặt` (sugar for `hằng _`) with `biến` — `đặt` creates an immutable binding.
#
# See also: hằng, biến, ←
# =============================================================================
# đặt — inferred immutable bindings
#
# Immediate init:
# đặt tên ← expr -- compact sugar for hằng _ tên ← expr
#
# Deferred init:
# đặt tên -- compact sugar for hằng _ tên (assign once later)
# tên ← expr
#
# Prefer đặt when a block chains several inferred locals; keep hằng _ when
# teaching the explicit infer marker or mixing typed and inferred bindings.
#
# GRAMMAR:
# sitDecl := 'đặt' IDENTIFIER ('←' expression)?
#
# EXPECTED OUTPUT:
# sit.expected
main {
let salve ← "Salve"
let tên ← "Marcus"
let nuntius ← "§, §!"(salve, tên)
print nuntius
let label
label ← "deferred"
print label
const _ idem ← nuntius
print idem
}Expected output:
Salve, Marcus!
deferred
Salve, Marcus!