You don't need that `size` field, if that is to always equal the initial `size`
parameter - it has to keep the same value in all instances and yet occupy
memory (4-8 bytes) in each of them. Compiler remembers the generic parameter
and can return it to you:
type
Object[size: static[int]] = object
list0 : array[size, int]
list1 : array[size, string]
list2 : array[size, float]
var o: Object[2]
echo o.size # Not a field, but rather a per-type constant
Run
Aside from not occuping memory at run-time, this way it cannot be changed and
so always keeps the correct value (`o.size = 3` won't compile).
# the wrong way
type
Object[size: static[int]] = object
size: int
list0 : array[size, int]
list1 : array[size, string]
list2 : array[size, float]
var o: Object[2]
o.size = 3
echo o.size # => 3; an irrelevant value
Run