Thanks, though I understand why we need to resolve macros. I don't
understand why non-macros need be resolved. Like in my example bar/print is
not a macro as macros ":include-macros true" is not specified in ns
definition.

On Tue, Aug 4, 2015 at 11:47 AM Derek Slager <[email protected]> wrote:

> 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 a topic in the
> Google Groups "ClojureScript" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/clojurescript/q9UaYC-X8XE/unsubscribe.
> To unsubscribe from this group and all its topics, 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.

Reply via email to