Re: supporting metadata caret reader syntax with deftype

2015-09-05 Thread Mike Rodriguez
I think Artur described it well. I don't think the docs are wrong. The thing is just understanding that the reader macro syntax is interpreted by the reader. The reader comes before the evaluation of the compiler (there is grey area here with read-eval but that's another topic). Since a

Re: supporting metadata caret reader syntax with deftype

2015-09-05 Thread Artur Malabarba
I had the same issue a couple of months ago. The thing to understand is that 'a is NOT a symbol. Actually, it evaluates to a symbol, which is a different thing. When you write ^{:a 1} 'a, it is the same as writing ^{:a 1} (quote a). So the metadata gets applied to the entire form, not the symbol.

supporting metadata caret reader syntax with deftype

2015-09-04 Thread Gregg Reynolds
I have a deftype that supports with-meta, but I can't figure out how to support caret reader syntax. To support with-meta, I include a "meta" field and implement IObj methods "meta" and "withMeta". Seems to work just fine: (with-meta (entity-map [:A/B] {:a 1}) {:foo "metadata here"}) But

Re: supporting metadata caret reader syntax with deftype

2015-09-04 Thread Gregg Reynolds
On Fri, Sep 4, 2015 at 11:30 AM, Gregg Reynolds wrote: > I have a deftype that supports with-meta, but I can't figure out how to > support caret reader syntax. > > To support with-meta, I include a "meta" field and implement IObj methods > "meta" and "withMeta". Seems to

Re: supporting metadata caret reader syntax with deftype

2015-09-04 Thread Gregg Reynolds
On Fri, Sep 4, 2015 at 7:51 PM, Mike Rodriguez wrote: > This has came up numerous times in other posts here. I can't hunt them > down currently but the quoted symbol issue you showed is just a > misunderstanding of how the reader macro for metadata works. > > Try (meta '^{:foo

Re: supporting metadata caret reader syntax with deftype

2015-09-04 Thread Mike Rodriguez
This has came up numerous times in other posts here. I can't hunt them down currently but the quoted symbol issue you showed is just a misunderstanding of how the reader macro for metadata works. Try (meta '^{:foo :bar} a) When you put the reader macro in front of the quote it is applied to