3 ms·
Author here. The repo link and simpler implementations were linked in sibling comments, so I'll just add a bit more explanation. The whole thing relies on the
by phoe-krk 5y ago
Author here. The repo link and simpler implementations were linked in sibling comments, so I'll just add a bit more explanation.
The whole thing relies on the idea that Lisp macros can communicate: the outer macros can, via their expansion, pass information to the inner macros via the compilation environment, and these inner macros can then use that information to decide how they should expand.
This information is available at compile-time only, but that's enough for the macros to decide what kind of code to generate - in this particular case, the choice is whether some body of code should be included in the expansion or not.
This mechanism is known in the Lisp world as the SYMBOL-MACROLET trick and was described well in the article at [0] - except I think that that article could use a slightly better example, which my repository is happy to provide.
[0] https://etc.ruricolist.com/2020/03/15/the-symbol-macrolet-trick/ https://etc.ruricolist.com/2020/03/15/the-symbol-macrolet-tr...
- deleted 5y ago[deleted]