我不明白如何获得完整的宏展开。
使用以下代码:
(when true (when true true))
我希望能够获得完整的宏展开。
(if true (do (if true (do true)))
但我无法
我理解macroexpansion-1
将解析第一级扩展:
(macroexpand-1 '(when true (when true true)))
(if true (do (when true true)))
但是为什么当我再次调用macroexpand-1
(这就是macroexpand
应该做的事情)时:
(macroexpand-1 '(if true (do (when true true))))
我得到了完全相同的结果。
(if true (do (when true true)))
我原本期望进行完整的宏展开。
宏展开仅适用于顶层表达式吗?
我知道在
clojure.walk
命名空间中有一个 expand-all
函数,因此我认为 macroexpand
不能用于嵌套结构。我对吗?