return
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Function returning a string literal via return \"string\".
Aliases: return
Syntax: return <string-literal>
Category#
transfer
Related#
Examples#
radix/corpus/redde/redde.fab (canonical · keyword)#
Returns a value from a function.
# =============================================================================
# return — Returns a value from a function.
# =============================================================================
#
# What this teaches:
# • Function return — `return <expression>` returns a value from a `fn`,
# and bare `return` returns `void`
# • Early returns with `if <cond> then return <expr>` for guard clauses
#
# Common mistakes:
# • Using `return` outside a function body — `return` is only valid inside `fn` declarations (SEM032).
#
# See also: →, ⇥, then, throw, pass
# =============================================================================
# return statements (function return)
#
# return <expression> -- return a value
# return -- return void (void)
#
# GRAMMAR:
# returnStmt :← 'return' expr?
#
# EXPECTED OUTPUT:
# 30, Salve, Munde, 42, 0, 20
fn adde(int a, int b) → int {
return a + b
}
fn saluta(string name) → string {
return "Salve, " + name
}
fn duoetquadraginta() → int {
return 42
}
fn tace() → void {
# bare return for void 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 return true and return false.
# =============================================================================
# return — Functions returning boolean literals via return true and return false.
# =============================================================================
#
# What this teaches:
# • Boolean return values — `return true` and `return false` are valid return
# expressions for `bool`-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 `bool`, not a list.
#
# See also: true, false, bool, fn
# =============================================================================
# scalar/return-bool — return boolean literals
#
# GRAMMAR:
# returnStmt :← 'return' 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 return 42.
# =============================================================================
# return — Function returning an integer literal via return 42.
# =============================================================================
#
# What this teaches:
# • Integer return values — `return 42` returns an integer literal from a
# `int`-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 `int`, not a list.
#
# See also: void, fn
# =============================================================================
# scalar/return-integer — return integer literal
#
# GRAMMAR:
# returnStmt :← 'return' 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 return \"string\".
# =============================================================================
# return — Function returning a string literal via return "string".
# =============================================================================
#
# What this teaches:
# • String return values — `return "string"` returns a string literal from a
# `string`-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 `string`, not a list.
#
# See also: string, fn
# =============================================================================
# scalar/return-string — return string literal
#
# GRAMMAR:
# returnStmt :← 'return' expr
#
# Verifies that the Swift backend emits a function returning a
# string literal (SC-001: primitives, functions, return).
fn da_textum() → string {
return "textus"
}