[Protocoled](https://github.com/b3liever/protocoled) is a nice example of macro 
that avoids a lot of repetition when you write an interface.
    
    
    import protocoled
    
    protocol PExpr:
       proc eval(e): int
       
       impl PLiteral:
          var x: int
          proc eval(e): int = e.x
          proc newLit(x: int): PLiteral =
             result = PLiteral(x: x)
       
       impl PPlusExpr:
          var a, b: PExpr
          proc eval(e): int = eval(e.a) + eval(e.b)
          proc newPlus(a, b: PExpr): PPlusExpr =
             result = PPlusExpr(a: a, b: b)
    
    
    Run

Also almost all of my repos are macros :-)

Reply via email to