العرضar

↤

Translation status: العربية reader-locale proof. Term names and code fences follow the ar 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

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