Thanks for the reply. It certainly worked correctly.

Actually, there is another problem I would like to solve. I want to make sure 
that =destroy correctly recognizes the Type in the following source code:
    
    
    type TypeKind = enum
      A = "A"
      B = "B"
    type Type[T: static TypeKind] = object
      id: Natural
    proc `=destroy`[T](x: var Type[T]) =
      echo "DESTROY ", typeof x, " id:", x.id
    
    var a {.used.} = Type[A](id: 1)
    var b {.used.} = Type[B](id: 0)
    
    # OUTPUT:
    # DESTROY Type[A] id:0
    # DESTROY Type[A] id:1
    
    
    Run

But now it does not work correctly. Compared to the example in the first post, 
the definition of x: T is missing from Type. I suspect that this makes the 
contents of Type[A] and Type[B] indistinguishable.

It would work if I implemented =destroy individually, as in the second example 
in the first post, but I'd like to avoid that as much as possible. Is there a 
better way to do this?

Reply via email to