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

Translation status: ภาษาไทย reader-locale proof. Code fences render through the th-TH pipeline; prose is canonical Latin.

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

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 — `fixum numerus n ↤ "42"` converts to the written
#     type, then initializes the binding.
#   • Inline recovery — `place ↤ value ⇥ fallback` stores the fallback only
#     when the conversion fails.
#   • Right-associated chains — `a ↤ b ↤ "42"` converts inner-to-outer and
#     stores each link.
#
# Common mistakes:
#   • using `↤` when the destination type is inferred — `fixum _ x ↤ …` is
#     rejected (no concrete conversion target).
#   • `⇥` recovery on ordinary `←` — legal only on `↤`.
#
# See also: ←, ↦, ⇥, fixum, varia
# =============================================================================

incipit {
    # Expression assignment: "42" converts to numerus through the ↦ route.
    varia numerus count  0
    count ↤ "42"
    nota count

    # Typed initialization: convert to the written type, then initialize.
    fixum numerus typed ↤ "7"
    nota typed

    # Inline recovery: "x" cannot parse as numerus, so ⇥ 0 is stored.
    varia numerus recovered  0
    recovered ↤ "x"0
    nota recovered

    # Right-associated chain: inner b converts first, then the inner result
    # feeds the outer conversion into a. Both links store 42.
    varia numerus a  0
    varia numerus b  0
    a ↤ b ↤ "42"
    nota a
    nota b
}

Expected output:

42
7
0
42
42