I'm trying to use metadata added by a macro in a macro but the metadata seems
to be missing.
Test case:
---- macrotest.clj ----
(ns macrotest)
(deftype Blarg [])
(defmacro ^Blarg blarg-macro []
"BLARG-MACRO")
(defmacro foo-macro [x]
(if (and (list? x)
(= (->> x first resolve meta :tag) Blarg))
"REPLACED-BLARG-MACRO"
x))
---- test.cljs ----
(ns test
(:require-macros macrotest))
(def a (macrotest/foo-macro (macrotest/blarg-macro)))
----
>From a Clojure repl, I get this *expected* result:
(macroexpand '(macrotest/foo-macro (macrotest/blarg-macro)))
=> "REPLACED-BLARG-MACRO"
However when I compile test.cljs to javascript I get this *unexpected* result:
test.a = "BLARG-MACRO";
I thought that since the metadata was also generated by clojure code that it
would be available to other clojure code during the clojurescript expansion
stage, but it looks like it isn't?
Ultimately what I'm trying to do is generate different code based on a known
return type for a macro form--perhaps there is a better way to do this in
clojurescript and I would appreciate any suggestions.
However, I'm still interested in why this code isn't working so I can correct
my mental model of the clojurescript macro expansion process.
--
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.