متغير
Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.
Declares a mutable binding.
Aliases: let, mutable
Syntax: متغير <type|_> <pattern> [← <expression>]
Category#
binding
Related#
Examples#
radix/corpus/varia/varia.fab (canonical · keyword)#
Declares a mutable binding.
# =============================================================================
# متغير — Declares a mutable binding.
# =============================================================================
#
# What this teaches:
# • Mutable bindings — `متغير` for values that can be reassigned after declaration
# • Immutable bindings — `ثابت` and `ليكن` for values that cannot be reassigned
#
# Common mistakes:
# • declaring متغير when the binding is never reassigned — use ثابت instead (WARN013)
#
# See also: ثابت, ←, ↑
# =============================================================================
# Mutable and immutable variable declarations
#
# متغير <اسم> ← <expr> -- mutable binding (may reassign)
# ثابت <اسم> ← <expr> -- immutable binding (see ثابت/fixum.fab)
#
# GRAMMAR:
# bindingStmt :← ('متغير' | 'ثابت') type? ident '←' expr
#
# EXPECTED OUTPUT:
# 0, 1, 11, "Salve, Mundus!", 30, "Vale"
main {
# --- Mutable bindings with متغير ---
var _ computus ← 0
print computus
computus ← 1
print computus
computus ← computus + 10
print computus
# --- Immutable bindings: ثابت _ and ليكن ---
const _ salutatio ← "Salve, Mundus!"
print salutatio
# ليكن compresses repeated ثابت _ when chaining inferred locals
let x ← 10
let y ← 20
let المجموع ← x + y
print المجموع
# --- Reassign only متغير bindings ---
var _ nuntius ← "Salve"
nuntius ← "Vale"
print nuntius
}Expected output:
0
1
11
Salve, Mundus!
30
Vale