type
OdArray*[As: static[int], T] = object
l: int
proc initOdArray*[As: static[int], T](len: int): OdArray[As, T] =
result.l = len
var test = initOdArray[10, int](100)
but I cannot get initOdArray to work, I get Error: type expected because the return of initOdArray is not understood as a type. Is there a way around this problem? So far the only approach I have found that works is to define a
proc init*[As: static[int], T](a: var OdArray[As, T]; len: int)
and pass the initOdArray as an argument after defining it but this is not the standard approach for initialization in Nim.
var test: OdArray[10, int] = initOdArray(100)
(have not checked, though)
That looks like a bug to me, worth submitting. Meanwhile you can try this:
type
OdArray*[As: static[int], T] = object
l: int
proc initOdArray*(T: typedesc, stlen: static[int], len: int): OdArray[stlen, T] =
result.l = len
var test = initOdArray(int, 10, 100)