↤
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
Conversion-directed assignment: evaluate the right side, convert it to the statically known type of the left place through the ↦ route, then assign.
Aliases: conversion-directed-assignment, conversio assign
Syntax: <place> ↤ <expression> [⊥ <recovery>]
Category#
assignment
Related#
Examples#
radix/corpus/assignatio/conversio-assign.fab (canonical · operator-group)#
Conversion-directed assignment: evaluate the right side, convert it to the statically known type of the left place through the ↦ route, then assign.
# =============================================================================
# ↤ — Conversion-directed assignment (U+21A4).
# =============================================================================
#
# What this teaches:
# • Expression assignment — `place ↤ value` converts `value` to the place's
# type through the existing `↦` route, then stores it exactly once.
# • Typed initialization — `คงที่ จํานวน n ↤ "42"` converts to the written
# type, then initializes the binding.
# • Inline recovery — `place ↤ value ⊥ fallback` stores the fallback only
# when the แปลง fails.
# • Right-associated chains — `a ↤ b ↤ "42"` converts inner-to-outer and
# stores each link.
#
# Common mistakes:
# • using `↤` when the destination type is inferred — `คงที่ _ x ↤ …` is
# rejected (no concrete แปลง target).
# • `⊥` default on ordinary `←` — legal only on `↤`; `⇥` never takes a value.
#
# See also: ←, ↦, ⊥, คงที่, แปร
# =============================================================================
เริ่ม {
# Expression assignment: "42" converts to จํานวน through the ↦ route.
แปร จํานวน count ← 0
count ↤ "42"
บันทึก count
# Typed initialization: convert to the written type, then initialize.
คงที่ จํานวน typed ↤ "7"
บันทึก typed
# Inline recovery: "x" cannot parse as จํานวน, so ⊥ 0 is stored.
แปร จํานวน recovered ← 0
recovered ↤ "x" ⊥ 0
บันทึก recovered
# Right-associated chain: inner b converts first, then the inner result
# feeds the outer แปลง into a. Both links store 42.
แปร จํานวน a ← 0
แปร จํานวน b ← 0
a ↤ (b ↤ "42")
บันทึก a
บันทึก b
}Expected output:
42
7
0
42
42