Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Syntax and reader by
retagged by

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" 

However, we cannot currently do so with defonce. We must resort to providing metadata manually as follows.

  ^{: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.

1 Answer

0 votes

We have an old ticket for this that has been through several rounds of patches, it's actually surprisingly tricky to get right. :)