การเรนเดอร์th-TH

generics

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.

Angle-bracket generic parameters on functions and declarations.

Aliases: type parameters, magnitudo

Syntax: ฟังก์ชัน name<T>(...) | ชนิด Name<T, ขนาด N>

Category#

type

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 `ขนาด` keyword.
#
# Common mistakes:
#   • Forgetting that `ขนาด` declares a compile-time integer generic parameter — regular types use bare `<T>` syntax.
#
# See also: ชนิดนามแฝง, ฟังก์ชัน
# =============================================================================

# generics — angle-bracket parameters (replaces removed prae ชนิดนามแฝง)
#
# GRAMMAR:
#   genericParams :← '<' (ident | 'ขนาด' ident) (',' (ident | 'ขนาด' ident))* '>'
#
# EXPECTED OUTPUT:
#   No เริ่ม — 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 ∪ none {
    return res.first()
}