为什么Clojure需要attr-map?

时间:2012-12-10 15:12:19

标签: clojure

我查看了谷歌和几本书,但找不到有关attr-map的文档。

(c/defmacro ^:clojure-special-form throw
  "Throw to the catch for TAG and return VALUE from it.
  Both TAG and VALUE are evalled."
  {:arglists '([TAG VALUE])}
  [tag value]

为什么attr-map需要尽管params矢量?也有人可以向我指出有关Clojure中元数据的详细资源。

1 个答案:

答案 0 :(得分:3)

在这种情况下不需要它。这是多余的。

user=> (defmacro ^:clojure-special-form throw   {:arglists '([TAG VALUE])} [tag value]   `(throw (Exception. ~tag ~value)))
#'user/throw
user=> (meta #'throw)
{:macro true, :ns #<Namespace user>, :name throw, :file "NO_SOURCE_PATH", :line 41, :arglists ([TAG VALUE]), :tag :clojure-special-form}

与之比较:

user=> (defmacro ^:clojure-special-form throw [tag value]   `(throw (Exception. ~tag ~value)))
#'user/throw
user=> (meta #'throw)
{:macro true, :ns #<Namespace user>, :name throw, :file "NO_SOURCE_PATH", :line 43, :arglists ([tag value]), :tag :clojure-special-form}

请参阅special forms的解释。

另请参阅:Learning Clojure: Meta Data