Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created April 15, 2011 03:07
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 swannodette/921056 to your computer and use it in GitHub Desktop.
Save swannodette/921056 to your computer and use it in GitHub Desktop.
(defmacro defrel [name & args]
(let [setsym (symbol (str name "-set"))
idxsym (symbol (str name "-indexed"))]
`(do
(defmacro ~name [~@args]
`(fn [a#]
(answers a# ~~setsym ~~idxsym [~~@args])))
(def ~setsym (atom #{}))
(def ~idxsym (atom {})))))
;; when the macro'ed macro is run I see
(fn [a__1307533__auto__]
(answers
a__1307533__auto__
#<Atom@4e22b7dc: #{}> ;; <-- I want symbols here
#<Atom@72402ecb: {}> ;; <-- and here
['even? q]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment