Fear of Macros

:: macros, Racket, software

I learned Racket after 25 years of mostly using C and C++.

Some psychic whiplash resulted.

“All the parentheses” was actually not a big deal. Instead, the first mind warp was functional programming. Before long I wrapped my brain around it, and went on to become comfortable and effective with many other aspects and features of Racket.

But two final frontiers remained: Macros and continuations.

I found that simple macros were easy and understandable, plus there were many good tutorials available. But the moment I stepped past routine pattern-matching, I kind of fell off a cliff into a terminology soup.

How do I write a non-trivial macro? It felt like the instructions to draw an owl.

How to draw an owl: 1. Draw some circles. 2. Draw the rest of the fucking owl.

I marinaded myself in material, hoping it would eventually sink in after enough re-readings. I even found myself using trial and error, rather than having a clear mental model what was going on. Gah.

Just as the shapes slowly started to emerge from the fog, I wrote:

Fear of Macros