You can trust the compiler a bit more. If you follow along with 
[http://zevv.nl/nim-memory/#_lets_talk_about_seqs](http://zevv.nl/nim-memory/#_lets_talk_about_seqs)
 and use that technique to look under the hood of an empty seq, youll see it's 
a nil pointer until you add data

So really, just use a seq!
    
    
    type
      Bar = object
        a,b:seq[int]
    
    proc seqToPtr[T](x: seq[T]): pointer {.inline, noSideEffect.} =
            when defined(nimSeqsV2):
              result = cast[NimSeqV2[T]](x).p
            else:
              result = cast[pointer](x)
    
    proc showPointers(b:Bar)=
      echo seqToPtr(b.a).repr
      echo seqToPtr(b.b).repr
    
    var x = Bar(a: @[1,2,3],b: @[])
    x.showPointers
    
    
    Run

Reply via email to