io! is a Clojure macro for marking code as unsuitable for transaction execution. When that code runs inside dosync, io! throws an exception instead of allowing the operation to continue. section 14.4
Rejecting I/O inside a transaction
f2 calls io! around println and is then passed to commute inside dosync. Calling f1 produces IllegalStateException: I/O in transaction. section 14.4
(def counter (ref 0)) (defn f2 [value] ; #1 (io! (println "Sorry, side effect on" value)) (inc value)) (defn f1 [] ; #2 (dosync (f2 (commute counter f2)))) (f1) ; #3 ;; IllegalStateException I/O in transaction user/f2
Trace io! from the side-effecting function through commute and dosync to the resulting exception. section 14.4
