Hey,

Thank you so much for the answer and the link. That is almost exactly how I was 
doing it, but for the sake of simplicity, I didn't give the full definitions in 
the diagram I provided.

However, my issue is not the generation of an AST combining multiple macro 
calls. It is that this generated AST is injected where these multiple modules 
all import and use.

Expanding the example in the diagram a little bit more:

  1. There is an `app.nim` that is imported by multiple modules, let's say 
`product.nim`, `supplier.nim`, and `customer.nim`.
  2. The generated AST contains constants defined based on these importing 
modules, for example `productTypeIndex = 1`, `supplierTypeIndex = 2`, and 
`customerTypeIndex = 3`.
  3. These modules will use the generated constants, for example 
`customer.toHtml()` proc (which is also generated) will use 
`app.customerTypeIndex`.



Of course if it was just these integers, it might have been better to have 
those in each generated module, but there are some large strings that are 
generated by combination of all the defined types.

**Update:** Idea about typed/untyped failed. Having typed/untyped arguments 
doesn't change the order of call for macros, even in the same module. Compiler 
calls all macros in the same order they are called in the source code with no 
phases if I understand correctly.

I will try to legacy option and/or go back to generating nim file for now. :)

Thank you all for the answers.

Reply via email to