Am 09.01.2011 um 22:52 schrieb mdzaebel:
> (meta ^:k []) --> {:tag :k}
> (meta ^:k 'o) --> nil
> (meta(with-meta 'o {:tag :k})) --> {:tag :v}
>
> Why doesn't the second line return the metadata?
Because 'o expands to (quote o) and you actually hint this list. You might try (meta ' ^:k o).
Sincerely
Meikel
Am 10.01.2011 um 01:10 schrieb Tim Robinson:
> You must have something messed up:
>
> In line 1 (meta ^:k []) does not return {:tag :k} it returns nil and
> I am using Clojure 1.2.
>
> Both lines 1 and 2, shouldn't return meta, because 'meta' only takes
> an object as an input argument.
> And only if the object already has metadata will metadata will return.
>
> => (def o (with-meta ['mydatastructure] {:k []}))
> => (meta o)
> {:k []}
Are you sure?
Clojure 1.2.0
user=> (meta '^:k o)
{:tag :k}
user=> (meta ^:k [])
{:tag :k}
user=> (meta (with-meta 'o {:tag :k}))
{:tag :k}
user=> (meta ^:k 'o)
nil
The ^ stuff all works in the reader. So meta always sees only one argument with metadata already attached. The question is: Where is the meta data attached?
Sincerely
Meikel