As an aside, Julia's MacroTools.jl defines pre- and post- code walking in four lines:<p><pre><code> walk(x, inner, outer) = outer(x)
walk(x::Expr, inner, outer) = outer(Expr(x.head, map(inner, x.args)...))
postwalk(f, x) = walk(x, x -> postwalk(f, x), f)
prewalk(f, x) = walk(f(x), x -> prewalk(f, x), identity)
</code></pre>
It's dead simple and obvious in retrospect, but I don't think I would have ever thought of that! I've always wondered if there's a lineage to this set of definitions. Does anyone know?
I love this sort of thing, but I often get the sense from Clojurists I’ve worked with that macros are seen as too complicated (even slightly naughty) for most codebases. Always seems a shame as it’s the main superpower you’re getting from Lisp.