Th documentation says that procedures marked with 'lent' return a hidden 
pointer. But the code below prints two different values which shows that a copy 
of the data is being returned instead of a pointer (Nim version 2.0.0 used) . I 
assume that I am misunderstanding how 'lent' works, can anyone clear up my 
confusion?
    
    
    type T = object
      x:seq[int]
    
    proc create():T =
      result.x = newseq[int](3)
    
    proc test( t:T ): lent seq[int] =
      t.x
    
    let t = create()
    echo cast[int](t.x[0].addr)
    let x = test(t)
    echo cast[int](x[0].addr)
    
    
    
    Run

The background to this topic is that I wish to extract sequencies from an 
object and use them without a copy being made. I was hoping that 'lent' would 
offer a neater alternative to 'move'ing sequencies out and then back into an 
object. 

Reply via email to