Re: re-def a non-dynamic var to a ^:dynamic var make a mistake

2011-12-08 Thread zhi zhu
Thanks Meikel !

It works after I recompile foo. It seems like you are right. :)

On Dec 8, 3:28 pm, Meikel Brandmeyer (kotarak) m...@kotka.de
wrote:
 Hi,

 just a guess: ^:dynmamic is a compile-time thing. foo was compiled without
 it in place, so the compiler didn't consider it. Recompile foo after the
 re-def with  ^:dynamic and it should honor the setting.

 Sincerely
 Meikel

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


re-def a non-dynamic var to a ^:dynamic var make a mistake

2011-12-07 Thread zhi zhu
Hi,everyone!
  I'm a newbie here.When I'm reading Mark Volkmann's Tutorial,i make a
mistake by binding a non-dynamic var 'x' to new value.Then I def 'x'
with ^:dynamic again,but in this line (binding [x 9] (foo)), the
function 'foo' ignore the binding.Why?
  Thanks for reply!!!

uer= (def x 0)
#'user/x

user= (defn foo [] (println x))
#'user/foo

user= (foo)
0
nil

user= (def ^:dynamic x 1)
#'user/x

user= (foo)
1
nil

user= (binding [x 9] (println x))
9
nil

user= (binding [x 9] (foo))
1
nil

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