With the latest from svn, I'm seeing the following weird behavior.

(def r (ref :old))
(let [old-value @r]
  (try
    (dosync (ref-set r :new))
    (finally
      (dosync (ref-set r old-value))
      )))
(println "@r is" @r)

This prints "@r is nil" whereas I'd expect it to print "@r is :old".
But the following prints "@r is :old" as expected:

(def r (ref :old))
(let [old-value @r]
  (try
    (dosync (ref-set r :new))
    (finally
      old-value       ; This line is the only difference
      (dosync (ref-set r old-value))
      )))
(println "@r is" @r)

The only difference is the do-nothing expression old-value that
immediately follows the finally. Am I missing something or is this a
bug?

I realize this is a very weird thing to be doing. In the real world
you'd want to have one (dosync ...) block, but this is for a macro for
unit tests where I want to be able to restore the proper value of a
ref after a test has had a chance to mess it up.

Thanks.
-hume.

-- 
http://elhumidor.blogspot.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to