generics
Translation status: 繁體中文 reader-locale proof. Code fences render through the zh-Hant pipeline; prose is canonical Latin.
Angle-bracket generic parameters on functions and declarations.
Aliases: type parameters, magnitudo
Syntax: functio name<T>(...) | genus Name<T, magnitudo N>
Category#
type
Related#
Examples#
radix/corpus/prae/prae.fab (canonical · concept)#
Angle-bracket generic parameters on functions and declarations.
# =============================================================================
# generics — Angle-bracket generic parameters on functions and declarations.
# =============================================================================
#
# What this teaches:
# • Type parameters — Functions and types can accept angle-bracket generic parameters like `<T>`.
# • Magnitudo parameters — Compile-time integer parameters use the `magnitudo` keyword.
#
# Common mistakes:
# • Forgetting that `magnitudo` declares a compile-time integer generic parameter — regular types use bare `<T>` syntax.
#
# See also: typus, functio
# =============================================================================
# generics — angle-bracket parameters (replaces removed prae typus)
#
# GRAMMAR:
# genericParams :← '<' (ident | 'magnitudo' ident) (',' (ident | 'magnitudo' ident))* '>'
#
# EXPECTED OUTPUT:
# No incipit — declaration or test-runner surface only.
#
# BACKEND:
# declaration-only generic surface (whitelist: prae/prae.fab). Cross-ref: generic/generic.fab.
#
fn identitas<T>(T value) → T {
return value
}
fn primum<T>(list<T> res) → T ∪ null {
return res.primus()
}