generic
Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.
Generic functions with angle-bracket type and 尺寸 parameters.
Syntax: 函式 <name><T, 尺寸 N>(<params>) → <type> <block>
Category#
type
Related#
Examples#
radix/corpus/generic/generic.fab (canonical · concept)#
Generic functions with angle-bracket type and 尺寸 parameters.
# =============================================================================
# generic — Generic functions with angle-bracket type and 尺寸 parameters
# =============================================================================
#
# What this teaches:
# • Generic functions with angle-bracket type and 尺寸 parameters.
# • Related keywords: 函式, 類型, 尺寸
#
# Common mistakes:
# • Type parameter not satisfying bounds — generic parameters must meet any constraints declared on the generic function or 類型.
#
# See also: 函式, 類型, 尺寸
# =============================================================================
# Generic functions with angle-bracket type parameters
#
# Type and size parameters appear in `<...>` before value parameters.
#
# GRAMMAR:
# funcDecl :← '函式' ident genericParams? '(' valueParams ')' ...
# genericParams :← '<' (ident | '尺寸' ident) (',' (ident | '尺寸' ident))* '>'
#
# EXPECTED OUTPUT:
# generic function signatures paratae
#
# BACKEND: Generic call codegen gap on Rust (`T: Clone`; whitelist: generic/generic.fab).
# Call sites are deferred in this smoke exemplar.
fn identitas<T>(T value) → T {
return value
}
fn primum<T>(list<T> res) → T ∪ none {
return res.first()
}
main {
print "generic function signatures paratae"
}Expected output:
generic function signatures paratae