On Sat, Jan 22, 2011 at 10:39 AM, Stuart Halloway <stuart.hallo...@gmail.com> wrote: >> 1. You could optionally put a docstring after the value of a normal >> def -- (def foo 17 "seventeen"). > > def has supported an optional doc string since 1.2. I have just updated the > wiki and docstring to reflect this.
My Clojure 1.2 REPL says otherwise: user=> (def x 32 "foo") #<CompilerException java.lang.Exception: Too many arguments to def (NO_SOURCE_FILE:73)> >> (defn foo >> "Docstring -- works currently" >> [x y] >> (+ (* x x) y)) > > AFAIK this has always worked. If you see this not working, please post > details to reproduce. Actually, it quasi-works. In both cases the var gets :doc "string" metadata. Only if the arity implementation is wrapped in parentheses does the function object itself also get the :doc "string" metadata. (And the arities metadata, and a lot of other metadata.) user=> (defn bar "foo" [x] (* x x)) #'user/bar user=> (meta bar) {:ns #<Namespace user>, :name bar} user=> (meta #'bar) {:ns #<Namespace user>, :name bar, :file "NO_SOURCE_PATH", :line 74, :arglists ([x]), :doc "foo"} user=> (defn bar "foo" ([x] (* x x))) #'user/bar user=> (meta bar) {:ns #<Namespace user>, :name bar, :file "NO_SOURCE_PATH", :line 74, :arglists ([x]), :doc "foo"} user=> (meta #'bar) {:ns #<Namespace user>, :name bar, :file "NO_SOURCE_PATH", :line 77, :arglists ([x]), :doc "foo"} user=> -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en