OK, let's say I have a array-type variable.

Is it possible to set it to... nothing?

I mean let's say a function takes an array parameter, with some (or no) values. 
I could obviously declare it as a seq, but then we would deal with memory 
allocation. I can also declare it as an openArray, and then I can pass both an 
array with values and an empty one, e.g.
    
    
    proc myFunc(a: openArray[int], b: openArray[int]) =
         ....
    
    myFunc([1,2,3],[])
    
    
    Run

Now, the problem arises when this array is e.g. part of an object. E.g.
    
    
        myobj = object
             a: openArray[int]
    
    
    Run

(I'm not allowed to do that)

If I try to define it as a c-style array, the definition goes well, but I 
cannot find a way to be able to set it to empty too. E.g.
    
    
       myobj = object
            a: array[5,int]
            b: array[5,int]
      
      myobj(a: [1,2,3,4,5], b: [])
    
    
    Run

In the case of b, it complains because it keeps expecting - exactly - 5 items.

How can I circumvent that, so that I can set any number of arguments, from 
zero(0) to 5? 

Reply via email to