Is it in specifications? type Type[T] = object id: Natural x: T echo Type[int] isnot Type[float] proc `=destroy`[T](x: var Type[T]) = echo "DESTROY ", typeof x, " id:", x.id var A {.used.} = Type[int](id: 1) var B {.used.} = Type[float](id: 0) Run
output: true DESTROY Type[system.int] id:0 DESTROY Type[system.int] id:1 Run In B, I want to call a destructor of type float. type Type[T] = object id: Natural x: T proc `=destroy`(x: var Type[int]) = echo "DESTROY ", typeof x, " id:", x.id proc `=destroy`(x: var Type[float]) = echo "DESTROY ", typeof x, " id:", x.id var A {.used.} = Type[int](id: 1) var B {.used.} = Type[float](id: 0) Run Above works fine, but it's a bit tedious. There is another problem: if `x: T` of above is no longer defined, either one destructor cannot be defined. If this is the spec, is there a workaround? I want to change the destructor process for each Type content.