Hi,
I'm trying to use the new overridable assignment operator together with destructors (to make a kind of smart pointer to wrap external resources). The assignment operator as well as the destructor both work in isolation, but if I define both, then only the assignment operator proc is called:
{.experimental.}
type
SmartPtr = object
id: int
proc `=`(dest: var SmartPtr, src: SmartPtr) =
echo "inc ", src.id
dest.id = src.id
proc `=destroy`(o: SmartPtr) =
echo "dec ", o.id
proc moo() =
let tmp = SmartPtr(id:11)
moo()
gives:
inc 11
but if I comment out "proc =", then I get:
dec 11
I wonder, is this expected, or a bug, or a I doing something wrong?