开发者

clojure.core unquote and unquote-splicing

At the top of the clojure.core file (below the comments and the namespace declaration) there are two definitions with no extra code or information:开发者_如何学C

(def unquote)
(def unquote-splicing)

What do these do/why are they there?


They are kind of dummy values. The reader expands ~x to (unquote x) and ~@x to (unquote-splice x). Lists of these types are then handled specially in syntax-quote.

Their declaration allows also their use outside of syntax-quote, e.g. in your own macros.

Since they are not bound to anything, their use outside of syntax-quote or a macro which handles them throws an exception.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜