Thanks to both for the responses, but I stil not clearly understand. The documentation says very clearly that:
In addition to with-meta, there are a number of reader macros (The Reader: Macro Characters) for applying metadata to the expression following it: ^{:doc "How obj works!"} obj - Sets the metadata of obj to the provided map. Equivalent to (with-meta obj {:doc "How obj works!"}) (def foo ^:abc [1 2 3]) -> (meta foo) -> {:abc true} (def foo ^:abc some-func) -> (meta foo) -> nil (def foo ^:abc 'some-symbol) -> (meta foo) -> nil (In clojure programming book uses example attaching metadata using the reader to the symbol, but seems it not works as expected) Is a little bit confusing. The metadata documentation says clearly that are equivalent, but are not equivalent. Thank you very much again. Regards. Andrey 2015-05-05 21:49 GMT+02:00 Andy- <andre.r...@gmail.com>: > In addition to James comment: IMO clojure.org/metadata should be clearer > about this. It's mentioned more clearly on the reader page: > http://clojure.org/reader#The%20Reader--Macro%20characters > "The metadata reader macro first reads the metadata and attaches it to > the next form read (see with-meta > <http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/with-meta> > to > attach meta to an object):" > > Stress on *next form read*. > > On Tuesday, May 5, 2015 at 2:31:40 PM UTC-4, Andrey Antukh wrote: >> >> Hi! >> >> I have some trouble with clojure metadata / reader and I do not know if >> I'm doing something wrong. >> >> I have this code: >> >> (defn some-func []) >> >> (def func ^:abc some-func) >> >> (assert (= (meta func) {:abc true})) >> >> (def data [[:bar (with-meta some-func {:abc true})] >> [:baz ^:abc some-func]]) >> >> (assert (= (meta (get-in data [0 1])) {:abc true})) >> (assert (= (meta (get-in data [1 1])) {:abc true})) >> >> It fails in the first assert and in the last (if I comment the first one >> obviously). I do not understand why that form of metadata does not works >> as I expect (http://clojure.org/metadata) >> >> Thank you very much. >> >> Regards. >> Andrey >> >> -- >> Andrey Antukh - Андрей Антух - <andrei....@kaleidos.net> / <ni...@niwi.be >> > >> http://www.niwi.be <http://www.niwi.be/page/about/> >> https://github.com/niwibe >> > -- Andrey Antukh - Андрей Антух - <andrei.anto...@kaleidos.net> / <n...@niwi.be > http://www.niwi.be <http://www.niwi.be/page/about/> https://github.com/niwibe -- 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 --- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.