Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rksm
Created August 4, 2014 01:35
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 rksm/562cd712cf843080cf4c to your computer and use it in GitHub Desktop.
Save rksm/562cd712cf843080cf4c to your computer and use it in GitHub Desktop.
Conditional call in Macro with gensym binding
(defmacro foo
[& [fn]]
`(let [env# 123]
~(when fn `(~fn env#))))
;; then expanded form of env does not match:
(macroexpand '(foo identity)) ;=> (let* [env__17699__auto__ 123] (identity env__17698__auto__))
@rksm
Copy link
Author

rksm commented Aug 4, 2014

The problem: auto gensyms only work in the form they were created in. To solve the issue, manual gensyms are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment