↤
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans 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