>> The idea is that foo will be defined and that {:foo-tag "blah"} is
>> added to its meta-data.

... and to explain *why*:

user=> (pprint
  (read-string "(defmacro my-defn [name & body]
   `(defn- #^{ :foo-tag \"blah\" } ~name []
      ~...@body))"))
(defmacro
  my-defn
  [name & body]
  (clojure.core/seq
   (clojure.core/concat
    (clojure.core/list 'clojure.core/defn-)
    (clojure.core/list name)
    (clojure.core/list
     (clojure.core/apply
      clojure.core/vector
      (clojure.core/seq (clojure.core/concat))))
    body)))

No mention of foo-tag in there.

#^ is a reader macro that annotates the next token read with metadata.  
It's not a form that persists into the macroexpansion, so it doesn't  
take effect in your generated defn-.

(There are good reasons for this, not just "that's the way it is": a  
macro is just like any other function, and you might want to add  
metadata such as type annotations just as you would in normal  
functions.)

Using with-meta *does* pass through into the macroexpansion, which is  
what you want.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to