Generics and Static types
!!! warning This auditors' handbook is frozen and obsolete; the Nim language manual alongside other Nim documentation, Status Nim style guide, Chronos guides, and Nim by Example supercede it.
Nim types can be parametrized by types (generics) or compile-time values (static)
For example
type
MySeq[T] = object
len, reserved: int
data: ptr UncheckedArray[T]
The generics can be restricted
type
MySeq[T: int32 or int64] = object
len, reserved: int
data: ptr UncheckedArray[T]
With static types
type
SmallSeq[MaxLen: static int, T] = object
len: int
data: array[MaxLen, T]