[nimx](https://github.com/yglukhov/nimx) solves this problem in a way inspired 
by Apple obj-c frameworks: 
    
    
    type
      View = ref object of RootObj
      Button = ref object of View
    
    method init*(v: View, r: Rect) {.base.} =
      echo "init view"
    
    proc new[T: View](t: typedesc[T], r: Rect): T =
      result.new()
      result.init(r)
    
    method init*(b: Button, r: Rect) =
      procCall b.View.init(r)
      echo "init button"
    
    let myButton = Button.new(makeRect(0, 0, 100, 100))
    

Reply via email to