Moving Execution to Compile Time
If you were playing golf, where the lowest number of strokes wins, would you rather get a hole-in-one or skip the hole entirely? Assuming that’s a legal thing to do (it’s not) and that you don’t enjoy playing the game in the first place (your mileage may vary), zero is clearly a better score than one.
When it comes to maintenance, the best code is no code at all.[20] The fastest code is code that doesn’t need to execute at runtime. In our case, the lowest number of instructions wins! Remember that we can consider macros as not even existing at runtime; this is a clear opportunity for us to speed things up.
The caveat is that in order to move expensive computations to compile time, we need access to all of the ...
Get Mastering Clojure Macros now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.