Pass all args from defonce on to def so it supports docstrings (or potentially other future features) just like def.
Docstrings and other Var metadata will be lost when the defonce is reƫvaluated.
Patch: clj-1148-defonce-6.patch
Screened by:
pull out of 1.6
This version looks for previously defined var with resolve. A repeated defonce won't affect the namespace at all if the variable is already defined and bounded.
Please confirm using (resolve '~name) is not a problem w.r.t ns-bindings or similar.
This patch also contains the tests from clj-1148-defonce-3.patch as well as the :arglists property.
(patch 4 missed one def-row, sorry for mailbox noise).
Yet another, simpler version of defonce. No test-cases included.
This version just makes an (or (nil? v#) (not (.hasRoot v#)) test on the resolved variable. If this is true, really define by (def ~name ~@args) else do nothing.
Linus, while JIRA can handle multiple attachments on the same ticket with identical names, it can be confusing to do so. Would you mind renaming or removing the ones you have added with duplicate names, e.g. delete obsolete ones, perhaps? Instructions for deleting patches are in the "Removing patches" section on this wiki page: http://dev.clojure.org/display/community/Developing+Patches
On noticing that we have a JIRA issue at work to add docstrings to the handful of defonce calls we have (via alter-meta!), I came upon this issue and wondered what is stopping it moving forward?
Is Linus's patch an acceptable solution overall (and is just missing tests)? Or is a different approach wanted? Is this blocked by and folks want that fixed before updating defonce?