`newTree` is the canonical way to use macros nowadays (if quote do is not enough).
Here are some examples of macros from my code: * [Simple] A very simple Add/Mul Domain Specific Language. Its AST is then translated into Nim AST and compiled: [https://github.com/mratsim/compute-graph-optim/blob/master/e08_DSL_compiler.nim](https://github.com/mratsim/compute-graph-optim/blob/master/e08_DSL_compiler.nim) * [Complex] There are further examples on the same repo on how I extend this DSL to apply to whole sequences and then introduce SIMD vectorization. The end goal is to create a deep learning compiler completely in Nim macro. Preview available here: [https://github.com/numforge/laser/tree/c7ddceb0d54390f622c48b7fcb4bb44964961d6d/laser/lux_compiler](https://github.com/numforge/laser/tree/c7ddceb0d54390f622c48b7fcb4bb44964961d6d/laser/lux_compiler) * [Simple] Create an enum without holes from an enum with holes declaration: [https://github.com/status-im/nimbus/blob/f4ff5336/nimbus/vm/interpreter/utils/macros_gen_opcodes.nim#L25-L83](https://github.com/status-im/nimbus/blob/f4ff5336/nimbus/vm/interpreter/utils/macros_gen_opcodes.nim#L25-L83) Usage: [https://github.com/status-im/nimbus/blob/7d74d385/nimbus/vm/interpreter/opcode_values.nim#L10-L183](https://github.com/status-im/nimbus/blob/7d74d385/nimbus/vm/interpreter/opcode_values.nim#L10-L183) * [Medium] Declarative configuration of an emulator opcodes: [https://github.com/mratsim/glyph/blob/8b278c5e/glyph/snes/opcodes.nim#L85-L127](https://github.com/mratsim/glyph/blob/8b278c5e/glyph/snes/opcodes.nim#L85-L127) Macro: [https://github.com/mratsim/glyph/blob/8b278c5e/glyph/snes/private/macros_opcodes.nim](https://github.com/mratsim/glyph/blob/8b278c5e/glyph/snes/private/macros_opcodes.nim) * [Complex] Declarative configuration of an assembler opcode -> machine code mapping: [https://github.com/numforge/laser/blob/e660eeeb/laser/photon_jit/x86_64/x86_64_ops.nim](https://github.com/numforge/laser/blob/e660eeeb/laser/photon_jit/x86_64/x86_64_ops.nim) Macro: [https://github.com/numforge/laser/blob/master/laser/photon_jit/x86_64/x86_64_op_generator.nim](https://github.com/numforge/laser/blob/master/laser/photon_jit/x86_64/x86_64_op_generator.nim) * [Complex] Variadic for-loop (note that it's more complex that needs be as I generate an iterator proc instead of iterating directly on arguments): [https://github.com/numforge/loop-fusion/blob/master/loopfusion.nim](https://github.com/numforge/loop-fusion/blob/master/loopfusion.nim)