Skip to content

Instantly share code, notes, and snippets.

@ponzao
Created April 20, 2011 09:15
Show Gist options
  • Save ponzao/930800 to your computer and use it in GitHub Desktop.
Save ponzao/930800 to your computer and use it in GitHub Desktop.
(defn- in-transaction [f]
(try
(do (println "starting...")
(let [rv (f)]
(println "commiting...")
rv))
(catch Exception e
(println "rollbacking..."))))
(defmacro transactional [expr]
`(in-transaction (fn [] ~expr)))
(transactional (+ 1 2 3 4)) ; -> 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment