ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Travis Smith
What does 'java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.IDeref' mean. I'm getting this a lot and I want to understand it better, make it easier for me to avoid this. Most of the time I just end up adjusting my def/defn's around until it works. This is

Re: ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Dave Ray
I think what you actually want is: (defn get-id [] (session/get :uid)) in your code, you're trying to call #'session/get directly and bind it to get-id. Of course, the problem with this is that #'session/get expects to be called in the context of a request which is where your Unbound var

Re: ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Stuart Campbell
Hi Travis, (def get-id (session/get :uid)) (defn set-user! [user] (session/put! :uid {:_id user})) Only set-user! is a function here. The value of get-id is evaluated at compile-time. I don't know about the implementation of noir.session/get, but the error message suggests that it uses

Re: ClassCastException clojure.lang.Var$Unbound Help

2012-04-30 Thread Travis Smith
Thank you for your responses. This was failing for me in the Noir server, so I assumed the same error meant the same thing in the REPL. Something was different though, changing it to (defn get-id ...) and a couple other minor tweaks and it's working. On Monday, April 30, 2012 9:31:17 PM