Slide 18 of 37

Generics

func first(v: T[]): Result<T, Bool> {
	if len(v) > 0 {
		return Result.Ok(v[0])
	}
	return Result.Error(false)
}

proc main(): void {
	a := first([1, 2, 3])       // first_Int
	b := first(["x", "y"])      // first_Str, a separate copy
	echo "{a} {b}"
}
A name in a signature that is neither a builtin nor a declared type is a type variable, and it makes the callable generic. A variable is pinned down by where it appears in the parameters — including inside a parameter's own function type. Nothing about it is dynamic at run time: every call site is resolved at compile time, and one concrete copy is emitted per distinct set of type arguments — first_Str, first_Int — with no boxing and no dispatch.