Skip to content

Instantly share code, notes, and snippets.

@amalloy

amalloy/eval.clj Secret

Created December 20, 2010 19:13
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 amalloy/3738c7ddac879aa790b1 to your computer and use it in GitHub Desktop.
Save amalloy/3738c7ddac879aa790b1 to your computer and use it in GitHub Desktop.
(eval
`(let [foo# 10]
(defmacro use-foo# [x#]
`(+ ~foo# ~x#))
(macroexpand '(use-foo# 5))))
;=> (clojure.core/+ 10 5)
(eval
`(let [foo# 10]
(defmacro use-foo# [x#]
`(+ ~foo# ~x#))
(use-foo# 5)))
;=> Wrong number of args (1) passed to: user$eval3352$use-foo--3348--auto--
(let [fname (gensym)
foo 10]
(eval
`(do
(defmacro ~fname [x#]
`(+ ~~foo ~x#))
(~fname 5))))
;=> 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment