Skip to content

Commit

Permalink
Replace refs with atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfa-ag committed Oct 12, 2015
1 parent 0aee1fa commit 90ba6ef
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/clojure/de/ljfa/mineclojure/command_clj.clj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
(.setDynamic (intern repl-ns 'me)) ;gets bound to the command sender

;get bound to *1, *2, *3 and *e
(def r1 (ref nil))
(def r2 (ref nil))
(def r3 (ref nil))
(def re (ref nil))
(def r1 (atom nil))
(def r2 (atom nil))
(def r3 (atom nil))
(def re (atom nil))

(defn -processCommand
[this sender args]
Expand All @@ -40,10 +40,9 @@
*1 @r1, *2 @r2, *3 @r3, *e @re]
(eval (read-string in-str))))]
(send-chat-lines sender (prettyprint output))
(dosync
(ref-set r3 @r2)
(ref-set r2 @r1)
(ref-set r1 output)))
(reset! r3 @r2)
(reset! r2 @r1)
(reset! r1 output))
(catch Throwable e
(dosync (ref-set re e))
(reset! re e)
(throw (CommandException. (str e) (into-array []))))))

0 comments on commit 90ba6ef

Please sign in to comment.