I read through all your posts on macros, Mike, thanks a lot.

Wrote some documentation on `defmacro` to elucidate these points 
(feedback/edits welcome):
https://github.com/cljsinfo/cljs-api-docs/blob/catalog/refs/cljs.core/defmacro.md

(hope to see more questions like this on the mailing list.  really helps drive 
the docs.)

On Sunday, September 13, 2015 at 3:32:45 PM UTC-5, Mike Fikes wrote:
> Self-hosted ClojureScript supports defmacro in the same way that regular 
> ClojureScript supports defmacro. In particular, macros must be defined 
> separately from runtime code. And, perforce, macros must be written in 
> ClojureScript (or, alternatively, they can be in a .clj file, so long as the 
> Clojure in that file happens to also be ClojureScript.)
> 
> 
> See this for more exposition on this:  
> http://blog.fikesfarm.com/posts/2015-06-19-portable-macro-musing.html
> 
> 
> Also, if you’d like to just mess around with macros within a self-hosted 
> ClojureScript REPL, it _is_ possible to do if you play games with the way 
> things work under the hood. This is covered in more detail here: 
> http://blog.fikesfarm.com/posts/2015-09-07-messing-with-macros-at-the-repl.html
> 
> 
> For your example below this ends up looking like:
> 
> 
> 
> cljs.user=> (ns foo.core$macros)
> nil
> foo.core$macros=> (defmacro m [x] `(- ~x))
> true
> foo.core$macros=> (foo.core/m 1)
> -1
> 
> 
> 
> - Mike
> 
> 
> 
> On Sep 13, 2015, at 10:43 AM, ZhX Chen <[email protected]> wrote:
> 
> In clojure:
> 
> => (defmacro m [x] `(- ~x))
> => (m 1)
> => -1
> 
> While in self-hosted clojurescript:
> 
> => (defmacro m [x] `(- ~x))
> => (m 1)
> => (- nil)
> 
> So this means self hosted clojurescript does not fully support the defmacro 
> yet?
> 
> -- 
> 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