Generics
Generic functions and structs with explicit instantiation at every call site.
Zmeu generics are explicitly instantiated: every generic call carries its type arguments at the call site. This keeps inference predictable and IR shapes stable.
Generic functions
Section titled “Generic functions”def identity[T](value: T) -> T: return value
def main() -> i32: let x: i32 = identity[i32](1) return xThe compiler monomorphises each instantiation; identity[i32] and identity[bool] produce separate, specialised functions.
Multi-parameter generics
Section titled “Multi-parameter generics”def unwrap_or[T, E](r: Result[T, E], fallback: T) -> T: let value: T = match r: Ok(x) => x Err(e) => fallback return valueCall sites supply both arguments: unwrap_or[i32, bool](r, 0).
Generic structs
Section titled “Generic structs”struct Box[T]: value: T
impl Box[T]: def get(self: view Box[T]) -> view T: return view self.valueGeneric struct methods use the surrounding impl’s type parameters after substitution.
Reserved for later
Section titled “Reserved for later”- Method-level type parameters (
def method[T](...)) insideimplblocks - Trait/typeclass bounds
- Higher-kinded constructs
These are deliberate deferrals: the language is staying simple until the rest of the surface settles.
Performance shape
Section titled “Performance shape”Because every instantiation is explicit and monomorphised, generic code lowers to the same LLVM IR shape as a hand-written specialised version. The IR-count regression suite covers this: generic identity, generic Option unwrap, and generic Result.try all show zero overhead vs equivalent C.