Created
February 1, 2013 17:08
-
-
Save jasonjohnson/4692634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def connection {:host "127.0.0.1"}) | |
(defn query [conn query] | |
(str (:host conn) ":" query)) | |
(defn query-with-modifiers [conn query modifiers] | |
(str (:host conn) ":" query ":" modifiers)) | |
(defmacro with-connection | |
[conn & body] | |
`(map (fn [op#] | |
(let [call# (resolve (first op#)) | |
args# (rest op#)] | |
(apply (partial call# ~conn) args#))) | |
(quote ~body))) | |
(with-connection connection | |
(query "q1") | |
(query "q2") | |
(query "q3") | |
(query-with-modifiers "q4" "my-modifiers")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment