学习如何编写 Clojure/Lisp 宏的书

发布于 2024-09-16 04:59:39 字数 1539 浏览 9 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

乖乖 2024-09-23 04:59:39

关于 Lisp 宏的经典书籍可能是 Paul Graham 的 On Lisp。虽然它使用了 Common Lisp,但如果您真正想查看它的宏,那么这并不重要,尽管 Clojure 在很多层面上都有所不同。 (首先,Clojure 是 Lisp-1。)

The quintessential book on Lisp macros is probably Paul Graham's On Lisp. It used Common Lisp, though, but that doesn't matter too much if what you really want to look at it macros, although Clojure's are different on a number of levels. (Clojure being a Lisp-1, to begin with.)

抚你发端 2024-09-23 04:59:39

尽管它们都是针对 Common Lisp,但 Paul Graham 所著的《On Lisp》中有两本很棒的书(完整书可在 他的网站)和Let Over Lambda 道格·霍伊特。

两者中,On Lisp 更容易理解;尽管 Clojure 宏与 IIRC 的 hygienic 宏更相似,但您几乎肯定会从中学到一些东西。

Although they're both aimed at Common Lisp, two great books for this are On Lisp by Paul Graham (full book available free online at his website) and Let Over Lambda by Doug Hoyte.

Of the two On Lisp is more accessible; even though Clojure macros are IIRC more similar to Scheme's hygienic macros, you'll still almost certainly learn something from it.

莫相离 2024-09-23 04:59:39

《实用Common Lisp》这本书把Lisp宏解释的非常清楚。 Clojure 的宏与 Common Lisp 的宏非常相似,几乎您所学到的所有内容都可以继承。 《Let Over Lambda》虽然是一部有趣、有趣且富有创意的作品,但它使用 Lisp 宏的方式与大多数认真、经验丰富、实用的 Lisp 程序员使用它们的方式非常不同。我不建议使用“变形”宏(“了解”特定变量名称)。

The book "Practical Common Lisp" explains Lisp macros very clearly. Clojure's macros are similar enough to those of Common Lisp that pretty much all of what you'd learn would carry over. "Let Over Lambda", while a fun, interesting, and creative work, uses Lisp macros very differently from the way they're used by most serious, experienced, practical Lisp programmers. I don't recommend the use of "anamorphic" macros (that "know" about specific variable names).

可爱暴击 2024-09-23 04:59:39

Michael Fogus 即将出版的书 The Joy of Clojure(可通过 Manning 的早期访问计划获取)中有关于宏的精彩章节。这是一本出色的书,解释了函数式编程背后的思维方式,不仅解释了 Clojure 的功能(包括最新的 1.2 更改)如何实现,还解释了为什么要这样实现。

关于宏的章节解释了 Clojure 中宏的以下用例、如何实现它们以及如何处理它们:

定义控制结构
组合形式
改变形式
返回表格
控制符号解析时间
管理资源

Michael Fogus' upcoming book The Joy of Clojure, available through Manning's Early Access Program, has a good chapter on macro's. It's an excellent book explaining the mindset behind functional programming, and not only how, but also why Clojure's features (including the newest 1.2 changes) are implemented the way they are.

The chapter on macro's explains the following use cases for macro's in Clojure, how they can be implemented, and how they are processed:

defining control structures
combining forms
changing forms
returning forms
control symbolic resolution time
manage resources

尹雨沫 2024-09-23 04:59:39

它不完全是一本通用的宏编写书,但 AMOP 演示了如何将宏用作库/框架的“视图”层。

(嗯,我没有很好地描述这一点。AMOP 是一本无法分类的书!)

It's not exactly a general-purpose macro-writing book, but AMOP demonstrates how to use macros as a 'view' layer for a library/framework.

(Hmm, I'm not doing a very good job describing this. AMOP is a book which kind of defies categorization!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文