exclude only annotation
ccfontes opened this issue · comments
Lets say I have a cljx source with a ns
declaration like this:
(ns #+clj ^{:doc "spam" :author "me"}
my.ns)
The resulting .cljs
would be:
(ns
)
but I would wish this in some way:
(ns
my.ns)
How do I prevent the ^{...}
from being included in the cljs
generated source, but not my.ns
also?
You can't, at least not like that. The metadata map is just as much much a part of the my.ns
value as the symbol itself.
You can elide entries in the metadata map, e.g.:
(ns ^{#+clj :doc #+clj "spam" :author "me"} my.ns)
@cemerick that was smart!
Finally I actually tried to use
the code generated for Clojurescript:
(ns ^{} my.ns)
in the REPL, but got this exception, when running (ns cljs.user (:use my.ns))
:
clojure.lang.ExceptionInfo: nth not supported on this type: Symbol at line 1 {:tag :cljs/analysis-error, :file nil, :line 1, :column 1}
After removing the #+clj
, it works of course.
It seems not even ^{}
is accepted in Clojurescript. Any ideas?
Insofar as namespace metadata is basically ignored by ClojureScript (not that it has much of a role in Clojure, for that matter), I'd suggest something like:
(ns #+cljs my.ns
#+clj ^{:metadata :here} my.ns
...)
It doesn't seem to ignore it here because it always throws an exception. Nevertheless, that alternative is simply awesome!
By "ignored", I meant that it has no practical use AFAIK.