TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

An introduction to deep code-walking macros with Clojure (2013)

76 pointsby fogusalmost 3 years ago

2 comments

cedalmost 3 years ago
As an aside, Julia&#x27;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 -&gt; postwalk(f, x), f) prewalk(f, x) = walk(f(x), x -&gt; prewalk(f, x), identity) </code></pre> It&#x27;s dead simple and obvious in retrospect, but I don&#x27;t think I would have ever thought of that! I&#x27;ve always wondered if there&#x27;s a lineage to this set of definitions. Does anyone know?
thomalmost 3 years ago
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.
评论 #31846679 未加载
评论 #31850321 未加载