Why ? Because I'm tired of writing assertions everywhere.
    
    
    type
      AtomicNode= refinement x: Node
        x.kind in AtomicNodes
    
    proc getParent(node: not AtomicNode): Node =
      impl
    
    
    Run

If it can't prove at CT that node is not AtomicNode, then it tries it in 
realtime. Generated code for realtime is like this (at place of call):
    
    
    var result =
      if not (x.kind in AtomicNodes):
        getParent(x)
      else:
        raise newException(ValueError, "refinement predicate failed")
    
    
    Run

see: <https://github.com/nim-lang/RFCs/issues/541>

Reply via email to