Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to document fields in a record in clojure?

Tags:

clojure

For example:

(defrecord Contract [^{:doc "primary identifiers..."} contract-id])

But this doesn't seem to work:

(doc Contract)

clojure.lang.Cons cannot be cast to clojure.lang.Symbol
[Thrown class java.lang.ClassCastException]

Maybe you can't document record fields?

like image 785
Chris Bilson Avatar asked Sep 22 '11 15:09

Chris Bilson


1 Answers

defrecord compiles a new class and uses these names as the fields of that class. Unfortunatly classes predate clojure and leave no room for metadata :(

The class will have the (immutable) fields named by
fields, which can have type hints.
like image 184
Arthur Ulfeldt Avatar answered Oct 13 '22 18:10

Arthur Ulfeldt