Renderingla

generic

Generic functions with angle-bracket type and magnitudo parameters.

Syntax: functio <name><T, magnitudo N>(<params>) → <type> <block>

Category

type

Related

Examples

examples/corpus/generic/generic.fab (canonical · concept)

Generic functions with angle-bracket type and magnitudo parameters.

# Generic functions with angle-bracket type parameters
#
# Type and size parameters appear in `<...>` before value parameters.
#
# GRAMMAR:
#   funcDecl :← 'functio' ident genericParams? '(' valueParams ')' ...
#   genericParams :← '<' (ident | 'magnitudo' ident) (',' (ident | 'magnitudo' 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.

functio identitas<T>(T valor) → T {
    redde valor
}

functio primum<T>(lista<T> res) → T ∪ nihil {
    redde res.primus()
}

incipit {
    nota "generic function signatures paratae"
}

Expected output:

generic function signatures paratae