Objects (without `ref`)are value types and those semantics also attach to their 
components. If you want to have shallow copying for objects, the easiest way is 
to use the `{.shallow.}` pragma.

Example:
    
    
    import deques
    
    type
        container[T] = object {.shallow.}
            val: seq[T]
    
    var c = container[int](val: @[1, 2, 3])
    echo repr(c.val)
    echo cast[int](c.val[0].addr)
    var deque = initDeque[container[int]]()
    deque.addFirst(c)
    var c2 = deque.popFirst()
    echo repr(c2.val)
    echo cast[int](c2.val[0].addr)
    

Note also that `a[1]` accesses the _second_ element of a `seq`. If you want the 
first element, use `a[0]`.

Reply via email to