Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created September 12, 2011 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxxxie/1212685 to your computer and use it in GitHub Desktop.
Save boxxxie/1212685 to your computer and use it in GitHub Desktop.
;;i want a macro that makes defs for me. examples
;;(def stores "localhost:5984/stores")
;;(defDB) works the way i want it to, (defDBs) does not
;;i get errors of the form (can't resolve do) or (string can't be an IF). i'm not sure what i'm doing wrong. i've tried many variations
;; my aim is (do (defDB store) (defDB inv))
(defmacro defDB [name]
`(def ~name ~(str *couchDB* name)))
(defmacro defDBs [& names]
`(concat (do) ~(map
(fn [name]
`(defDB ~name))
names)))
(pprint (macroexpand-1 '(defDB store)))
(pprint (macroexpand-1 '(defDBs store inv)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment