In Nim 2.0, destructors now accept a parameter of type T instead of var T. Are there any recommended approaches to maintaining backward compatibility in existing code?
My attempt was:
when compiles(block:
type O = object
proc `=destroy`(self: O) = discard
):
const newDestructors = true
else:
const newDestructors = false
And then writing two versions of destructors for the object.
Is there a more optimal solution?
The system libs seems use
const arcLike = defined(gcArc) or defined(gcAtomicArc) or defined(gcOrc)
when defined(nimAllowNonVarDestructor) and arcLike:
...