> So, the only places I think a single .cljc file can be used as the source of both runtime and macro code is regular JVM ClojureScript and regular Clojure.
Not sure I understand why is that. As library author I'd try to write as much code as possible in cljc file without any conditionals so that same file without any changes used by both clojurescript and clojure. Ideally I want bootstrapped cljs to be able to compile it as well. For example it is pure utility library without any platform-specific features. Couple of functions and couple of macros. All in one cljc file without any conditionals. Why can't bootstrapped load this file with "macros: false" and ignore all defmacro to load only functions and then load it with "macros: true" and take only defmacro into account? May be I don't really understand why it is ok for clojure to intermix functions and macros but not ok for boostrapped cljs. Clojure runs only on jvm and bootsrapped cljs only on js so it should not have limitations of jvm cljs. On Sat, Feb 20, 2016 at 4:02 PM Mike Fikes <[email protected]> wrote: > There are a few fundamental facts that shape my thinking on this question: > > 1) .clic files are the only place reader conditionals are allowed. [1] > > 2) When code is compiled using bootstrapped ClojureScript, the :cljs > branch is always followed. > > 3) In bootstrapped ClojureScript, .cljc is used only as a fallback when > .cljs and .clj files cannot be found for runtime and macro code > respectively. [2] (I suspect this load ordering preference is also true for > JVM ClojureScript.) > > So, the only places I think a single .cljc file can be used as the source > of both runtime and macro code is regular JVM ClojureScript and regular > Clojure. > > For JVM ClojureScript, I've referred to this "loading twice" as the "loop" > pattern of arranging compilation stages [3]. > > And for Clojure, you can inherently freely intermix macros and functions > in either .clj or .cljc files. > > I can't think of a way to do this with bootstrapped ClojureScript. For > bootstrapped ClojureScript you could have any of these arrangements: > > Runtime Code Macro Code > foo.cljs foo.clj > foo.cljs foo.cljc > foo.cljc foo.clj > > [1] http://clojure.org/reference/reader#_reader_conditionals > [2] > https://github.com/clojure/clojurescript/blob/r1.7.228/src/main/cljs/cljs/js.cljs#L59-L63 > [3] > http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html > > > -- 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 https://groups.google.com/group/clojurescript.
