渲染zh-Hans

sit

Translation status: 简体中文 reader-locale proof. Code fences render through the zh-Hans pipeline; prose is canonical Latin.

Declares an inferred immutable local.

Syntax: sit <name> [← <expression>]

Category#

binding

Examples#

radix/corpus/sit/sit.fab (canonical · keyword)#

Declares an inferred immutable local.

# =============================================================================
# sit — Declares an inferred immutable local.
# =============================================================================
#
# What this teaches:
#   • Immutable binding sugar — `sit name` is a compact alternative to
#     `fixum _ name` for inferred-type immutable locals
#   • Supports immediate init (`sit x ← expr`) and deferred init
#     (`sit x` then `x ← expr` later)
#
# Common mistakes:
#   • Confusing `sit` (sugar for `fixum _`) with `varia` — `sit` creates an immutable binding.
#
# See also: fixum, varia, ←
# =============================================================================



# sit — inferred immutable bindings
#
# Immediate init:
#   sit nomen ← expr        -- compact sugar for fixum _ nomen ← expr
#
# Deferred init:
#   sit nomen               -- compact sugar for fixum _ nomen (assign once later)
#   nomen ← expr
#
# Prefer sit when a block chains several inferred locals; keep fixum _ when
# teaching the explicit infer marker or mixing typed and inferred bindings.
#
# GRAMMAR:
#   sitDecl := 'sit' IDENTIFIER ('←' expression)?
#
# EXPECTED OUTPUT:
#   sit.expected

main {
    let salve  "Salve"
    let nomen  "Marcus"
    let nuntius  "§, §!"(salve, nomen)

    print nuntius

    let label
    label  "deferred"
    print label

    const _ idem  nuntius
    print idem
}

Expected output:

Salve, Marcus!
deferred
Salve, Marcus!