การเรนเดอร์th-TH

อนุมานคงที่

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.

Declares an inferred immutable local.

Syntax: อนุมานคงที่ <name> [← <expression>]

Category#

binding

Examples#

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

Declares an inferred immutable local.

# =============================================================================
# อนุมานคงที่ — Declares an inferred immutable local.
# =============================================================================
#
# What this teaches:
#   • Immutable binding sugar — `อนุมานคงที่ name` is a compact alternative to
#     `คงที่ _ name` for inferred-type immutable locals
#   • Supports immediate init (`อนุมานคงที่ x ← expr`) and deferred init
#     (`อนุมานคงที่ x` then `x ← expr` later)
#
# Common mistakes:
#   • Confusing `อนุมานคงที่` (sugar for `คงที่ _`) with `แปร` — `อนุมานคงที่` creates an immutable binding.
#
# See also: คงที่, แปร, ←
# =============================================================================



# อนุมานคงที่ — inferred immutable bindings
#
# Immediate init:
#   อนุมานคงที่ ชื่อ ← expr        -- compact sugar for คงที่ _ ชื่อ ← expr
#
# Deferred init:
#   อนุมานคงที่ ชื่อ               -- compact sugar for คงที่ _ ชื่อ (assign once later)
#   ชื่อ ← expr
#
# Prefer อนุมานคงที่ when a block chains several inferred locals; keep คงที่ _ when
# teaching the explicit infer marker or mixing typed and inferred bindings.
#
# GRAMMAR:
#   sitDecl := 'อนุมานคงที่' IDENTIFIER ('←' expression)?
#
# EXPECTED OUTPUT:
#   sit.expected

main {
    let salve ← "Salve"
    let ชื่อ ← "Marcus"
    let nuntius ← "§, §!"(salve, ชื่อ)

    print nuntius

    let label
    label ← "deferred"
    print label

    const _ idem ← nuntius
    print idem
}

Expected output:

Salve, Marcus!
deferred
Salve, Marcus!