是否有可能在clojure中记录记录中的字段?
问题描述:
(defrecord Contract [^{:doc "primary identifiers..."} contract-id])
但这似乎并没有工作:
(doc Contract)
clojure.lang.Cons cannot be cast to clojure.lang.Symbol
[Thrown class java.lang.ClassCastException]
也许你不能文档记录的字段?
答
defrecord编译一个新类,并使用这些名称作为该类的字段。不幸的课程早于clojure并留下元数据的空间:(
The class will have the (immutable) fields named by fields, which can have type hints.