On Oct 4, 2009, at 5:04 PM, Mark Volkmann wrote:
Minor technicality ... Vars are a reference type, but deref and @ don't work with them.
I'm guessing you're thinking of an interaction like this:
user=> (def a 3)
#'user/a
user=> @a
java.lang.ClassCastException: java.lang.Integer cannot be cast to
clojure.lang.IDeref (NO_SOURCE_FILE:0)
user=>
However, it's important to remember that the expression "a" does not
evaluate to the Var named "a". The Var named by "a" can be accessed
via (var a) or #'a.
deref does work with Vars:
user=> @(var a)
3
user=> @#'a
3
user=>
deref works with objects that implement clojure.lang.IDeref and
clojure.lang.Var is among them:
user=> (isa? clojure.lang.Var clojure.lang.IDeref)
true
user=>
--Steve
smime.p7s
Description: S/MIME cryptographic signature
