de
Translation status: 繁體中文 reader-locale proof. Code fences render through the zh-Hant pipeline; prose is canonical Latin.
Introduces borrowed iteration or borrowed parameters.
Syntax: de <expression>
Category#
iteration
Related#
Examples#
radix/corpus/de/de.fab (canonical · keyword)#
Introduces borrowed iteration or borrowed parameters.
# =============================================================================
# de — Introduces borrowed iteration or borrowed parameters.
# =============================================================================
#
# What this teaches:
# • Borrowed iteration — `itera de <expr> fixum <ident> { ... }` iterates over a collection without taking ownership.
# • Tabula key iteration — iterating over tabula keys via borrowed iteration.
# • Index iteration — iterating over lista indices via `de`.
#
# Common mistakes:
# • Passing a `de` parameter to an `in` or `ex` position — mode mismatch; cannot pass a read-only reference where mutation or consumption is expected (SEM057).
#
# See also: ex, in
# =============================================================================
# de — borrowed iteration / parameters
#
# GRAMMAR:
# forDeStmt :← 'itera' 'de' expr 'fixum' ident block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: itera/de.fab.
#
main {
const map<string, int> persona ← { "nomen": 1, "aetas": 30 }
for ref persona const clavis {
print clavis
}
const _ numeri ← [10, 20, 30]
for ref numeri const index {
print index
}
}radix/corpus/itera/de.fab (canonical · keyword)#
Introduces borrowed iteration or borrowed parameters.
# =============================================================================
# de — Introduces borrowed iteration or borrowed parameters.
# =============================================================================
#
# What this teaches:
# • borrowed iteration (`itera de`) over tabula keys and lista indices — iterates without consuming the collection
# • accessing values by key or index within a borrowed loop
#
# Common mistakes:
# • Using de (key/index iteration) when ex (value iteration) is needed, or vice versa — de iterates keys/indices, ex iterates values.
#
# See also: ex, in
# =============================================================================
# itera de — for-in key and index iteration
#
# itera de <objectum> fixum <key> { <body> }
# itera de <lista> fixum <index> { <body> }
#
# GRAMMAR:
# forDeStmt :← 'itera' 'de' expr 'fixum' ident block
#
# EXPECTED OUTPUT:
# none — stdout not pinned for this exemplum.
main {
# Iterate over tabula keys
const map<string, string> persona ← { "nomen": "Marcus", "urbs": "Roma" }
for ref persona const clavis {
print clavis
}
# Access values using the key
for ref persona const clavis {
print clavis, persona[clavis]
}
# Iterate over lista indices
const _ numeri ← [10, 20, 30]
for ref numeri const index {
print "index: § valor: §"(index, numeri[index])
}
# With numerus-valued tabula
const map<string, int> forma ← { "alpha": 1, "beta": 2 }
for ref forma const k {
print k
}
}