On Sun, Oct 4, 2009 at 4:26 PM, Stephen C. Gilardi <squee...@mac.com> wrote:
>
> 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)

Yes, that's what I was thinking about.

> 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=>

Thanks for clarifying that!

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to