I'm not too sure of your end goal but Nim is a static language so types must be 
known at runtime, you can't pass them a a string.

Also your type is generic over int or float so you need to use the generic 
syntax:
    
    
    type
      MyArray*[T: int|float] = ref object
        length*: int
        index: int
        arr: seq[T]
    
    proc createMyArray[T: int|float](length: int, tp: typedesc[T]): MyArray[T] =
      result = MyArray[T](
        length: length,
        index: 0,
        arr: newSeq[T](length)
      )
    
    var ma = createMyArray(1000, float)
    
    
    Run

Reply via email to