Macros are resolved at compile time, so bar/print will be transformed to the result of running the macro *during compilation*, not to something that's called at runtime. The "less trivial" example from David's post demonstrates the simplest possible scenario. The example code[1] loads a simple macro[2] via XHR, resulting in:
original source: (mult 4 4) after macro is processed: (* 4 4) after transpile to js: 4 * 4 Notice also that the reference to bar.core is gone in the transpiled source. Derek 1. https://github.com/swannodette/swannodette.github.com/blob/master/code/blog/src/blog/cljs_next/core.cljs#L138 2. http://swannodette.github.io/assets/cljs/bar/core.clj On Tue, Aug 4, 2015 at 11:30 AM Nikita Beloglazov <[email protected]> wrote: > I've played a little bit with client-side compilation and don't entirely > understand the role of *load-fn* when non-macros namespace is used ( > https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs#L76 > ). > > I see the need to load source file with macros (so that they can be > evaluated and change code), but if my namespace includes - how its source > is used for compilation? > > Example: > > (ns my.ns > (:require [foo.bar :as bar])) > > (defn say-hello [name] > (bar/print "Hello" name)) > > > Why source of foo.bar is needed to compile this code? I believe (bar/print > ...) will be compiled to foo.bar.print(...) any way. > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
