io!

added
1.0

ns
clojure.core

type
macro

(io! & body)

If an io! block occurs in a transaction, throws an
IllegalStateException, else runs body in an implicit do. If the
first expression in body is a literal string, will use that as the
exception message.

                user=> (def a (ref 0))
#'user/a

user=> (dosync
         (io! (println "hello"))
         (alter a inc))
IllegalStateException I/O in transaction

user=> (dosync
         (println "hello")
         (alter a inc))
"hello"
1

user=> (defn fn-with-io []
         (io! (println "hello")))
#'user/fn-with-io

user=> (dosync
         (fn-with-io)
         (alter a inc))
IllegalStateException I/O in transaction