I'm trying to get documentation using the Clojure doc
function, but can't get it recognized from the REPL (I'm using Emacs and SLIME). The following sequence describes what's going on (error message follows immediately after each line):
gaidica.core> (doc first)
; Evaluation aborted.
Unable to resolve symbol: doc in this context
[Thrown class java.lang.Exception]
gaidica.core> (clojure.core/doc first)
; Evaluation aborted.
No such var: clojure.core/doc
[Thrown class java.lang.Exception]
user> (clojure.core/doc first)
; Evaluation aborted.
No such var: clojure.core/doc
[Thrown class java.lang.Exception]
user> (doc first)
-------------------------
clojure.core/first
([coll])
Returns the first item in the collection. Calls seq on its
argument. If coll is nil, returns nil.
nil
user>
How do I refer to the doc
function and get it recognized as a function, not a variable?
ADDENDUM, 6/22/11, 9 hours after question posted
@kotarak made the most relevant comment: "Note, that clojure.core/doc is 1.2 and earlier. clojure.repl/doc is 1.3 and later." Sure enough, the following worked:
user> (clojure.repl/doc first)
-------------------------
clojure.core/first
([coll])
Returns the first item in the collection. Calls seq on its
argument. If coll is nil, returns nil.
nil
user>
I was able to confirm that Clojure 1.3 was active:
user> *clojure-version*
{:interim true, :major 1, :minor 3, :incremental 0, :qualifier "master"}
user>
But this too was confusing--my Leiningen project.clj had specified Clojure 1.2!
In my own experience, I once noticed that the SLIME-based REPL "hung onto" a Java classpath value even after I changed the contents of relevant directories. The solution then was to exit Emacs and lein swank
, then re-enter both and try again. I tried the same and got the following result:
user> *clojure-version*
{:major 1, :minor 2, :incremental 0, :qualifier ""}
user>
The only conclusion I can make is that my previous REPL had been using Clojure 1.3. The project that I worked on previous to this had used a Clojure 1.3 snapshot, so I'm guessing that the REPL had "hung onto" Clojure 1.3 somehow.
Problem solved, lesson learned, etc. For bonus points, can anybody explain the reason for what happened (with Clojure 1.2 vs. 1.3)?
Thanks to all who contributed.