Ah! Thanks to all.
Yes, I was a bit confused, thinking ^ expands as ' (quote), to use (with-meta..). But there is not expansion. It really applies the map to the next read form, expecting the read form implements IObj: public interface IObj extends IMeta { public IObj withMeta(IPersistentMap meta); } So. ^{ .... } applied to a symbol, returns a new symbol. From Symbol.java: public IObj withMeta(IPersistentMap meta){ return new Symbol(meta, ns, name); } I have seen the light! ;-) Time to refactor my code, TDD will save my day Angel "Java" Lopez @ajlopez On Sat, May 3, 2014 at 6:51 PM, Stephen Gilardi <scgila...@gmail.com> wrote: > I just read: > > > http://clojure.org/reader > > > - Metadata (^) > Metadata is a map associated with some kinds of objects: Symbols, > Lists, Vector, Sets, Maps, tagged literals returning an IMeta, and record, > type, and constructor calls. 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): > ^{:a 1 :b 2} [1 2 3] yields the vector [1 2 3] with a metadata map of > {:a 1 :b 2}. > > > Ok, but how the reader works? > > > The description above is literally how it works: "The metadata reader > macro first reads the metadata and attaches it to the next form read”. > > Reader macros are implemented within the reader. They are distinct from > defmacro macros. > > The implementation is here: > > https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/LispReader.java#L706 > > The reader reads from an input stream; it: > > - reads the metadata object, meta [L716] > - reads the object that follows it, o [L724] > - figures out how to apply meta to o based on the interface(s) o > implements [L725.L731] > - applies meta to o [L733,L741] > > —Steve > > -- > 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. > -- 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.