Is it because the def form can also be ^:dynamic?
At any rate, I did an attempt at my first macro to create a (def- ...) form, but it doesn't seem to work. Can you not attach metadata in a macro?
(defmacro def- "Why (defn- private-fn ...) but (def ^:private var ...)?" [sym & body] `(def ^:private ~sym ~@body)) ;; => #'user/def- user> (macroexpand '(def- blah "foo bar quux")) ;; => (def blah "foo bar quux")
Stig
Have you tried with-meta?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Is it because the
defform can also be^:dynamic?
At any rate, I did an attempt at my first macro to create a (def- ...) form, but it doesn't seem to work. Can you not attach metadata in a macro?
2015-05-07 16:12 GMT+02:00 Stig Brautaset <sbrau...@gmail.com>:Is it because the
defform can also be^:dynamic?Hm, cognitect turned it down, because basically "if you go down this road, why stop with def- ? and before you know, you've got a core namespace full of def*-"
Can you not attach metadata in a macro?
You can, but it works differently than in normal source. Remember, that ^ attaches metadata the literal, that you annotate. so ^:private ~sym is the symbol ~sym with a private metadata key. The quasiquoting, however, rebuilds the form and inserts the sym parameter in place of the ~sym form. So to attach the metadata to actual def'ed symbol, you need to attach it to the output, the macro generates, like this: `(def ~(with-meta sym {:private true}) ...)
--