我对Clojure的compojure库中的一些代码有疑问.
(defn compile-route
"Compile a route in the form (method path & body) into a function."
[method route bindings body]
`(make-route
~method ~(prepare-route route)
(fn [request#]
(let-request [~bindings request#] ~@body))))
Run Code Online (Sandbox Code Playgroud)
我只看到了在宏的上下文中使用的gensyms,它们用于防止宏中使用的绑定和本地作用域中的绑定之间的冲突.
我认为,由于以上是一个功能而不是宏,它对此免疫.因此,我想知道像宏一样编写这个函数的理由是什么.
(如果你想知道,我检查了提交历史,看看这个函数最初是作为一个宏编写的.它不是.)