redde
Translation status: Tiếng Việt reader-locale proof. Code fences render through the vi pipeline; prose is canonical Latin.
Function returning a string literal via redde \"textus\".
Aliases: return
Syntax: redde <string-literal>
Category#
transfer
Related#
Examples#
radix/corpus/redde/redde.fab (canonical · keyword)#
Returns a value from a function.
# =============================================================================
# redde — Returns a value from a function.
# =============================================================================
#
# What this teaches:
# • Function return — `redde <expression>` returns a value from a `functio`,
# and bare `redde` returns `vacuum`
# • Early returns with `si <cond> ergo redde <expr>` for guard clauses
#
# Common mistakes:
# • Using `redde` outside a function body — `redde` is only valid inside `functio` declarations (SEM032).
#
# See also: →, ⇥, ergo, iace, tacet
# =============================================================================
# redde statements (function return)
#
# redde <expression> -- return a value
# redde -- return void (vacuum)
#
# GRAMMAR:
# returnStmt :← 'redde' expr?
#
# EXPECTED OUTPUT:
# 30, Salve, Munde, 42, 0, 20
fn adde(int a, int b) → int {
return a + b
}
fn saluta(string nomen) → string {
return "Salve, " + nomen
}
fn duoetquadraginta() → int {
return 42
}
fn tace() → void {
# bare redde for vacuum return type
return
}
fn porta(int x) → int {
if x < 0 {
# early return on negative input
return 0
}
return x * 2
}
main {
print adde(10, 20)
print saluta("Munde")
print duoetquadraginta()
tace()
print porta(-5)
print porta(10)
}Expected output:
30
Salve, Munde
42
0
20
radix/corpus/scalar/return-bool.fab (canonical · keyword)#
Functions returning boolean literals via redde verum and redde falsum.
# =============================================================================
# redde — Functions returning boolean literals via redde verum and redde falsum.
# =============================================================================
#
# What this teaches:
# • Boolean return values — `redde verum` and `redde falsum` are valid return
# expressions for `bivalens`-typed functions
# • Demonstrates that boolean literals pass through the return statement
# unchanged
#
# Common mistakes:
# • Confusing a scalar (single-value) return with a collection return — this function returns one `bivalens`, not a list.
#
# See also: verum, falsum, bivalens, functio
# =============================================================================
# scalar/return-bool — return boolean literals
#
# GRAMMAR:
# returnStmt :← 'redde' expr
#
# Verifies that the Swift backend emits functions returning
# boolean literals (SC-001: primitives, functions, return).
fn da_verum() → bool {
return true
}
fn da_falsum() → bool {
return false
}radix/corpus/scalar/return-integer.fab (canonical · keyword)#
Function returning an integer literal via redde 42.
# =============================================================================
# redde — Function returning an integer literal via redde 42.
# =============================================================================
#
# What this teaches:
# • Integer return values — `redde 42` returns an integer literal from a
# `numerus`-typed function
# • Verifies the backend emits the correct primitive type for integer returns
#
# Common mistakes:
# • Confusing a scalar (single-value) return with a collection return — this function returns one `numerus`, not a list.
#
# See also: vacuum, functio
# =============================================================================
# scalar/return-integer — return integer literal
#
# GRAMMAR:
# returnStmt :← 'redde' expr
#
# Verifies that the Swift backend emits a function returning an
# integer literal (SC-001: primitives, functions, return).
fn da_numerum() → int {
return 42
}radix/corpus/scalar/return-string.fab (canonical · keyword)#
Function returning a string literal via redde \"textus\".
# =============================================================================
# redde — Function returning a string literal via redde "textus".
# =============================================================================
#
# What this teaches:
# • String return values — `redde "textus"` returns a string literal from a
# `textus`-typed function
# • Verifies the backend handles string literal return types correctly
#
# Common mistakes:
# • Confusing a scalar (single-value) return with a collection return — this function returns one `textus`, not a list.
#
# See also: textus, functio
# =============================================================================
# scalar/return-string — return string literal
#
# GRAMMAR:
# returnStmt :← 'redde' expr
#
# Verifies that the Swift backend emits a function returning a
# string literal (SC-001: primitives, functions, return).
fn da_textum() → string {
return "textus"
}