Re: Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
Maybe now I understand: Proc parameters are unmutable in Nim, so there is no reason to destroy the copy. Only when inside the proc we have var myVal = myprocPar then we get a new mutable instance, which is destroyed. And my feeling is that = proc is never used for passing parameters to procs,

Re: Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
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

Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
I was just thinking about how I can prevent a call of destroy from within a proc, because for callbacks we do not want destroy calls for parameters owned by GTK. But it seems that this tests does not generate a destroy call for proc parameter at all? type O {.bycopy.} =