var mp = MatchPool3 Also, can I create new MatchPool of certain int in runtime in the heap? (N is not known in compile time)
To straight up give an example it's like this:
type MatchPool[N: static[int]] = object
vals: array[N, int]
var mp = MatchPool[3](vals: [2, 4, 1])
There's no easy way to provide default values for such integer generic parameters, is there? E.g. (this doesn't work):
type MatchPool[N: static[int] = 3] = object ....
I'm glad i came across this thread, because i ran into a very ugly error with:
type
Thing[I] = object
things: array[I, int]
echo Thing[5]()
# Error: unhandled exception: int128.nim(72, 11) `arg.sdata(2) == 0` out of range [AssertionError]
Changing it to Thing[I: static[int]] fixes it but the error made me think i hit a compiler bug.