Hi,
Am Samstag, 28. Januar 2012 19:48:23 UTC+1 schrieb raschedh:
Maybe the meta info is attached to (quote a) and not to the symbol, because
> that is "the next form read" ?
>
Exactly.
When I say
> (def z1 (with-meta [] {}))
> and
> (def z2 ^{} [])
> again,
> only
> (meta z1) gives me my content-rich meta information back,
> but
> (meta z2) returns nil.
>
> What am I missing ?
>
The former replaces the metadata on the vector. The latter merges the map
into existing metadata of the symbol. This allows for example "(def
^Frobnicator ^:dynamic foo ...) ". However in your example the original
metadata is nil. And you don't merge things in it. So it stays nil.
See the relevant code here:
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L735
Plus the fact that assoc on nil produces a map.
Hope that helps.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en