I would really like to answer your question with yes, but I do not entirely 
understand your question.

Does your own answer mean you already answered the question yourself?

Just one hint from me who already wrote a few more macros.

instead of this:
    
    
    case definition.kind
    of nnkProcDef:
      [...]
    else:
      error([...])
    

you can do this: `definition.expectKind(nnkProcDef)`

And for the AST generation I really recommend you to use `quote do:` as much as 
possible, even for smaller code sections. The advantage is not only that it is 
more readable, but also nodes generated with `quote do:` have positional 
information, meaning when you get an error in your macro you actually get to 
know where the error comes from. One thing that you should take care of though 
when you try this approach is that you need to assign expressions to 
identifiers first before you can insert them in the ast.
    
    
    let something = generateSomethingNode([...])
    result = quote do:
      bananas = `something` * 3
    

Reply via email to