Skip to content

Instantly share code, notes, and snippets.

@ddillinger
Created April 11, 2012 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddillinger/2359425 to your computer and use it in GitHub Desktop.
Save ddillinger/2359425 to your computer and use it in GitHub Desktop.
Clojure wat
user=> (def bs '[a 1 b 2])
#'user/bs
user=> (type bs)
clojure.lang.PersistentVector
user=> (vector? bs)
true
user=> (let bs (+ a b))
java.lang.IllegalArgumentException: let requires a vector for its binding (NO_SOURCE_FILE:0)
@scgilardi
Copy link

I know you're clear on what's going on here, but I think it's interesting how many different meanings bs has here.

(def <a var with name the symbol bs> '[a 1 b 2])

(type <the value bound to the var named by the symbol bs>)

(vector? <the value bound to the var named by the symbol bs>)

(let <the symbol bs> (+ a b))

and the error would be a lot clearer if it said:

let requires a vector literal as its first argument, found a symbol: bs

@ddillinger
Copy link
Author

Yeah, and for someone "in the know" it is trivial to demonstrate what happened:

user=> (defmacro foo [thingy] (type thingy))
#'user/foo
user=> (foo bs)
clojure.lang.Symbol

But this sort of thing can be so bewildering to fresh clojure programmers, and the error is effectively telling you to do exactly what you did, as far as a naive inspection might discover.

It makes me feel bad for the newbies :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment