2

I'm going through the Joy of Clojure book and ran into the following series of errors in Ch. 2:

(def make-list0 #(list))
=> (var cursive-test.core/make-list0)
(make-list0)
IllegalStateException Attempting to call unbound fn: #'cursive-test.core/list  clojure.lang.Var$Unbound.throwArity (Var.java:43)
(def make-list2 #(list %1 %2))
=> (var cursive-test.core/make-list2)
(make-list2 1 2)
IllegalStateException Attempting to call unbound fn: #'cursive-test.core/list  clojure.lang.Var$Unbound.throwArity (Var.java:43)
(def make-list2+ #(list %1 %2 %&))
=> (var cursive-test.core/make-list2+)
(make-list2+ 1 2 3 4 5)
IllegalStateException Attempting to call unbound fn: #'cursive-test.core/list  clojure.lang.Var$Unbound.throwArity (Var.java:43)

I'm not sure what is going on here. I'm using IntelliJ IDEA with the Cursive plugin. Any ideas?

1
  • for whatever reason the unqualified list isn't getting resolved to clojure.core/list. I don't remember enough about Clojure namespaces to suggest a fix though. Commented Jun 29, 2014 at 18:51

1 Answer 1

2

Somehow you accidentally defined something called list in your own namespace, but didn't give it a value. One way you could accidentally do this would be to use a def inside a function, but never actually call that function:

(defn foo [x]
  (def list x))

The solution is to not do that, and the easiest way to get back to normalcy is to restart your repl and reload the namespace once it no longer has this incorrect redefinition of list in it. If you can't find where you've defined it, note that reloading the namespace should also print a warning message telling you you're redefining list, which I think includes a line number, but I don't recall for sure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.