TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

76 点作者 fogus将近 3 年前

2 条评论

ced将近 3 年前
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?
thom将近 3 年前
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 未加载