(def ^{:doc "Implements Fib. sequence lazily."} fibs ...)
(:doc (meta (var fibs)))
; "Implements Fib. sequence lazily."
Just write a macro so you can write (def-with-docs foo "doc" 1) .
(defmacro def-with-docs [name docstring value] `(def ~(with-meta name {:doc docstring}) ~value)) (def-with-docs fib-seq "Implements Fibbonaci sequence (starts with 0)." ((fn rfib [ab] (lazy-seq (cons a (rfib b (+ ab))))) 0 1))
(:doc (meta (var fib-seq)))
; "Implements Fibbonaci sequence (starts with 0)."
Also, note that with your defn example, a docstring must precede the arguments, otherwise it will not be associated with the character metadata.
Alternatively, you can use clojure.contrib.def / defvar .
source share