clausura
Translation status: 简体中文 reader-locale proof. Code fences render through the zh-Hans pipeline; prose is canonical Latin.
Declares or explains an inline closure expression; compact ∴ syntax is preferred for new code.
Syntax: <type> <name> [→ <type>] [⇥ <error-type>] ∴ <expression|fac-block>
Category#
function
Related#
Examples#
radix/corpus/clausura/clausura.fab (canonical · keyword)#
Declares or explains an inline closure expression; compact ∴ syntax is preferred for new code.
# =============================================================================
# clausura — Declares or explains an inline closure expression; compact ∴
# syntax is preferred for new code.
# =============================================================================
#
# What this teaches:
# • Closure basics — `∴` (therefore) introduces a closure body after the
# parameter list
# • Compact syntax — the `∴` form is preferred over block-delimited closures
# for simple expressions
#
# Common mistakes:
# • confusing `∴` (clausura joint for compact closures) with `ergo` (single-statement body joint for `si`, `dum`, `casu`) — they are not interchangeable
#
# See also: ∴, functio, fac, cape, cede
# =============================================================================
# clausura — closure bodies with ∴ and ⇥
#
# GRAMMAR:
# closureExpr :← paramList '∴' expr
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: clausa/clausa.fab.
#
main {
const _ dupla ← int x ∴ x * 2
print dupla(5)
const _ summa ← (int a, int b) → int ∴ a + b
print summa(2, 3)
}Expected output:
10
5