So I think my code should have a shape like this, that should be OK:
    
    
    type
      O[K] = object {.inheritable.}
        i: K
      
      O2[K] = object of O[K]
        h: int # special field for optimizations
    
    proc d[K](o: O[K] | O2[K]) =
      when o is O2: echo "doing optimizations"
    
    var h1: O[int]
    var h2: O2[int]
    
    d(h1)
    d(h2)
    
    

Reply via email to