I am currently reading the Programming Clojure book and have come
across an unexpected result for an example in section titled "Managing
Per-thread state with Vars".

Code snippet is as follows (with expected result):

user> (def foo 10)
#'user/foo

user=> (.start (Thread. (fn [] (println foo))))
nil
| 10

I tried the above using the clojure trunk version and my output is
that println line didn't print anything:

user> (.start (Thread. (fn [] (println foo))))
nil

However, if I try the version of clojure that accompanies the book
examples then the "println foo" in the new thread prints the expected
value of 10.

user=> (.start (Thread. (fn [] (println foo))))
nil
| 10

Does this make any sense? If so, why the difference?

Regards,
-Alen

PS. I'm new to clojure and I am absolutely loving it so far.
(Especially Clojure's very neat Concurrency API.)
--~--~---------~--~----~------------~-------~--~----~
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