Skip to content

Instantly share code, notes, and snippets.

Created July 6, 2014 00:16
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 anonymous/9c839217c56642250639 to your computer and use it in GitHub Desktop.
Save anonymous/9c839217c56642250639 to your computer and use it in GitHub Desktop.
Sub-macro Issues
(defmacro unit [a b] `[(quote ~a) ~b])
(defmacro collect [& z] `(let [~'a 3 ~'b 7] (eval (apply concat (list 'cond) [~@z]))))
;works fine...
;(macroexpand-all '(collect (unit (< 2 3) "Object A") (unit (> 2 3) "Object B")))
;(let* [a 3 b 7] (clojure.core/eval (clojure.core/apply clojure.core/concat (clojure.core/list (quote clojure.core/cond)) [[(quote (< 2 3)) "Object A"] [(quote (> 2 3)) "Object B"]])))
;has issues
;(macroexpand-all '(collect (unit (< a 3) "Object A") (unit (> b 3) "Object B")))
;(let* [a 3 b 7] (clojure.core/eval (clojure.core/apply clojure.core/concat (clojure.core/list (quote clojure.core/cond)) [[(quote (< a 3)) "Object A"] [(quote (> b 3)) "Object B"]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment