Clojure宏展开 [英] Clojure macroexpand
本文介绍了Clojure宏展开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么
(macroexpand '(.. arm getHand getFinger))
扩展到
(. (. arm getHand) getFinger)
同时
(macroexpand '(-> arm getHand getFinger))
扩展到
(getFinger (clojure.core/-> arm getHand))
换句话说,为什么在第二个示例中->
没有完全展开?
In other words, why is the ->
not expanding fully in the second example?
推荐答案
macroexpand
仅扩展形式,直到函数位置中的符号不是宏为止.在->
情况下注意到这一点的原因是因为->
宏是递归的.
macroexpand
only expands the form until the symbol in the function position is not a macro. The reason why you notice this in the case of ->
is because the ->
macro is recursive.
在您的情况下,您需要macroexpand-all
表clojure.walk
In your case, you want macroexpand-all
form clojure.walk
这篇关于Clojure宏展开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文