I can rewrite it this way: O {.bycopy.} = object i: int proc new(o: var O) = echo "new called" proc `=destroy`*(s: var O) = echo "=destroy called" proc `=sink`*(a: var O; b: O) = echo "=sink called" a.i = b.i proc createO: O = result.i = 7 proc p(o: sink O) = echo "working with o" echo o.i proc main = var o: O = createO() p(o) echo o.i main() nim Run $ ./h =sink called working with o 7 7 =destroy called Run
So p() has a sink parameter. But should not the echo after call of p() force a copy, so that we get two destroys?