Created
April 11, 2012 13:52
-
-
Save ddillinger/2359425 to your computer and use it in GitHub Desktop.
Clojure wat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
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
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