I am a Nim n00b, and one of the hardest things I am having trouble with is 
dealing with arrays in Nim.

I have the following typedef
    
    
    type GlyphArray* = array[100,  NVGglyphPosition]
    type
      TextBuffer* = tuple
        position        : tuple[ x : float, y : float ]
        cursor          : tuple[ row : int, col : int ]
        glyphPositions  : GlyphArray
        linePositions   : seq[tuple[ start: int, stop: int]]
        text            : string
    

I would like to be able to instantiate a new TextBuffer tuple as follows:
    
    
    var my_text : TextBuffer = (position: (25.0, 25.0), cursor: (0,0), 
glyphPositions: GlyphArray, linePositions: @[(0,0)], text:"")
    

But That gives me a type mismatch error because GlyphArray is a typeDesc, not 
an instantiated type.

I need to create separate variable for the program to compile correctly:
    
    
    var glyphs : GlyphArray
    var my_text : TextBuffer = (position: (25.0, 25.0), cursor: (0,0), 
glyphPositions: glyphs, linePositions: @[(0,0)], text:"")
    

This seems awkward to me.

Is there a cleaner way to do this? Is there a way to instantiate an array 
inside the construction of a tuple?

Reply via email to