For completeness, here is how the destructor for a `ref object` subtype would 
be coded:
    
    
    type ARef = ref object of RootRef
      aname: string
    
    proc `=destroy`(x: typeof ARef()[]) =
      `=destroy`(x.aname)
    
    type BRef = ref object of ARef
      bname: string
    
    proc `=destroy`(x: typeof BRef()[]) =
      `=destroy`(x.bname)
      `=destroy`((typeof ARef()[])(x))    # This is how the base type's 
destructor is called
    
    
    Run

Reply via email to