Your object has a dynamic type, but it doesn't have a vtable, because there's 
no such thing in Nim. echo is calling the $ proc defined on Node, so that's 
what you get. If you want runtime polymorphism then you can use methods:
    
    
    type
      Node = ref object of RootObj
        children: seq[Node]
      
      ExtNode = ref object of Node
        ext: bool
    
    var
      n0 = ExtNode()
      n1 = ExtNode()
    
    method `$`(n: Node): string =
      "no ext here"
    
    method `$`(n: ExtNode): string =
      "ext=" & $n.ExtNode.ext
    
    n0.children.add(n1)
    n0.children.add(Node())
    
    echo n0.children[0]
    echo n0.children[1]
    
    
    Run

prints
    
    
    ext=false
    no ext here
    

Reply via email to