When defining vars, we can provide docstrings in between the symbol and the binding. e.g.
(def some-var
"this var serves as an example"
42)
However, we cannot currently do so with defonce
. We must resort to providing metadata manually as follows.
(defonce
^{:doc "this var serves as another example"}
other-example nil)
It would be nice to be able to use docstrings like we can in def
, defn
, etc. in a future release of Clojure.