Kết xuấtvi

generic

Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.

Generic functions with angle-bracket type and kích_thước parameters.

Syntax: hàm <name><T, kích_thước N>(<params>) → <type> <block>

Category#

type

Examples#

radix/corpus/generic/generic.fab (canonical · concept)#

Generic functions with angle-bracket type and kích_thước parameters.

# =============================================================================
# generic — Generic functions with angle-bracket type and kích_thước parameters
# =============================================================================
#
# What this teaches:
#   • Generic functions with angle-bracket type and kích_thước parameters.
#   • Related keywords: hàm, kiểu, kích_thước
#
# Common mistakes:
#   • Type parameter not satisfying bounds — generic parameters must meet any constraints declared on the generic function or kiểu.
#
# See also: hàm, kiểu, kích_thước
# =============================================================================

# Generic functions with angle-bracket type parameters
#
# Type and size parameters appear in `<...>` before value parameters.
#
# GRAMMAR:
#   funcDecl :← 'hàm' ident genericParams? '(' valueParams ')' ...
#   genericParams :← '<' (ident | 'kích_thước' ident) (',' (ident | 'kích_thước' 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