(defmacro with-env
"Binds the global env to env, then executes the body"
[env & body]
`(let [env# ~env
env# (cond
(map? env#) (atom env#)
(and (instance? clojure.lang.Atom env#)
(map? @env#)) env#
:default (throw (ex-info (str "global env must be a map or atom containing a map, not "
(class env#))
{:env env#})))]
(binding [*env* env#] ~@body)))