seen this?

https://gist.github.com/alandipert/4669472

"ClojureScript does not have a standalone macro system. To write
ClojureScript macros, one must write them in Clojure and then refer to them
in ClojureScript code. This situation is workable, but at a minimum it
forces one to keep ClojureScript code and the macros it invokes in separate
files. I miss the locality of regular Clojure macros, so I wrote something
called maptemplate that gives me back some of what I miss. The technique
may be useful in other scenarios"

On Wed, Mar 11, 2015 at 3:36 AM, Peter West <[email protected]> wrote:

> Thanks Matt and Karsten.  You've clarified the issues for me quite
> nicely.  IIUC, again, the clojurescript compilation process is taking place
> exclusively in a clojure/jvm environment.  If that is the case, macro
> expansion must also, necessarily, occur in that clojure/jvm environment.
> If that is the case, what difference does it make if defmacro appears in a
> file with a .cljs extension?
>
> It seems to me that the difference is that it greatly complicates the
> compiler.  Just looking at function definitions, including executing code
> within defmacros, there are three cases.  1) Pure agnostic clojure, 2)
> functions with java interop, and 3) functions with js interop.  (And, I
> suppose, functions with both forms of interop, which can be rejected
> immediately.)  2) is only valid during macro expansion, 3) is valid
> wherever macro expansion is not being perfomed, and 1) is always valid.
> The compiler could, I imagine, be obliged to sort that lot out, effectively
> creating .clj files on the fly, and allowing all agnostic code to fall
> thorough to code emission, where redundant, macro only, functions can be
> dealt with by dead code elimination.  However, as I said, that would
> complicate the work of the compiler.
>
> Thanks again for the feedback on this.
>
> On Tuesday, 10 March 2015 06:13:02 UTC+10, Matt Greer  wrote:
> > How could macros written in ClojureScript execute if ClojureScript isn't
> self hosted? There needs to be some kind of runtime to execute the macro,
> and currently the only runtime available is the JVM.
> >
> >
> >
> > On Wed, Mar 4, 2015 at 9:03 PM, Peter West <[email protected]> wrote:
> > On Thursday, 5 March 2015 05:31:49 UTC+10, Stuart Sierra  wrote:
> >
> > Thanks to all for the replies.
> >
> >
> >
> > Stuart, I wasn't thinking about self-hosting; merely about unifying the
> experience under Clojure and ClojureScript, wrt macros.  Some work has
> already been done towards this, and I was wondering whether it were
> feasible to integrate defmacro into the CLJS compiler.  I thought there may
> be subtleties around the fact that CLJS appears to be an essentially AoT
> environment.
> >
> >
> >
> > In the event that there are no structural impediments, we might look
> forward to such a full integration of defmacro some time down the track.  I
> think it would be a boon for the wider acceptance of CLJS.
> >
> >
> >
> >
> >
> > > On March 3, 2015, Peter West wrote:
> >
> > > > Macros eventually all expand to CLJS-compatible code.
> >
> > > > Currently, IIUC, both macro definition and expansion are
> >
> > > > handled by the Clojure compiler, with the resulting code
> >
> > > > (presumably CLJS compatible) being handed back to the
> >
> > > > ClojureScript compiler. Was this simply a convenience to
> >
> > > > get CLJS working with a minimum of fuss, or are there some
> >
> > > > structural impediments?
> >
> > >
> >
> > >
> >
> > > Mostly, I think, it was the quickest path to bootstrap the
> >
> > > ClojureScript compiler. Clojure already had a reader and
> >
> > > macro expander, so ClojureScript used them.
> >
> > >
> >
> > > In Rich Hickey's original design, ClojureScript was not
> >
> > > intended to be self-hosting without the JVM. The past few
> >
> > > years of work have brought ClojureScript closer to the
> >
> > > *possibility* of self-hosting, but it hasn't been a priority
> >
> > > for most of the major contributors.
> >
> > >
> >
> > > -S
> >
> >
> >
> > --
> >
> > 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.
> >
> >
> >
> >
> >
> > --
> >
> >
> > Matt
>
> --
> 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.

Reply via email to