Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; ^:dynamic will be required to allow rebinding in Clojure 1.3
- (def *schema-imports*
- (hash-map))
- (defmacro with-schema-imports
- "Executes body with schema elems (given as vector of symbol, keywords, or
- strings) imported and thus referrable by their simple name."
- [elems & body]
- (letfn [(keyval [qn]
- (let [qstr (name qn)
- lof (. qstr lastIndexOf ".")
- sn (. qstr substring (inc lof))]
- [sn qstr]))]
- (let [keyvals (mapcat keyval elems)]
- `(binding [*schema-elems* ~(apply assoc *schema-imports* keyvals)]
- ~@body))))
- ;; That works fine in the defining namespace, but in a different one (the test namespace) I get:
- Unable to resolve var: funql.core/*schema-elems* in this context
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement