boogie February 2016
clojure/script expanding a macro into multiple 'def's inside a 'do' block
Not sure if valid question, but i'm learning macros and i'm trying to write a macro (for clojurescript but should be same thing) so i can do nicer js/require in node.
The syntax will look like this:
(import ["some-module" :as module1]
["some-other-module" :as module2])
and it would expand to this:
(def module1 (js/require "some-module")
(def module2 (js/require "some-module"))
My question is:
Is it ok to do 'def' inside a do block?
cljs does not seem to complain, but is it ok from a macro design stand point?
gfredericks February 2016
Yes, using the
(do (def ...) (def ...)) pattern is generally the only way to
def multiple things in a macroexpansion.
Asked in February 2016
Viewed 3,523 times
Answered 1 times
Leave an answer
Quote of the day: live life