/
11.05.2025 at 02:19 pm
Cuttings

Nim Macros - Beginner & Intermediate Exercises

With detailed notes and thought processes.

I've been practising metaprogramming with Nim recently.

I've not found macros to be simple, or at least not as simple as the phrase 'code substitution' itself suggests.

Thus I took extensive notes while doing these exercises, which I leave here in their entirety. I hope they will help your understanding should you be newly dipping your toes in the topic of macros. (Leave a note if you find them helpful!)

Each exercise builds on earlier knowledge, so you may want to study/try them in order. I've verified the example code to work, but let me know otherwise.


  1. Beginner Level: quote do & backticks

  2. Intermediate Level: basic AST use

Filed under:
#
#
Words: 177 words approx.
Time to read: 0.71 mins (at 250 wpm)
Keywords:
, , , , , , , , ,

Potentially related: Reflections - 43 Things I Learned or Did In 2019

Latest Comments

© Wan Zafran. See disclaimer.