Why doesn't this work?
user=> (meta ^{:some-meta 123} 'n)
nil
While this works:
user=> (meta ^{:some-meta 123} (fn [n] n))
{:some-meta 123}
And this works too:
user=> (meta (with-meta 'n {:some-meta 123}))
{:some-meta 123}
Is this intended behavior? If so, what's the reasoning?
Thanks,
Sarki
to get the meta-data of a var (I'm guessing symbol n refers to a var...)
you should call it on the var iself, not its value or symbol:
user=> (def ^{:some-meta 123} n 0)
#'user/n
user=> (meta n)
nil
user=> (meta 'n)
nil
user=> (meta #'n)
{:some-meta 123, :ns #, :name n, :file "NO_SOURCE_PATH",
There was just this question the other day:
http://stackoverflow.com/questions/30922413/why-does-metadata-symbol-not-work
There is also a few threads a few weeks ago here on google groups about it:
https://groups.google.com/d/msg/clojure/_e7vBom2acw/0AAKTiGuzv4J
HTH
On Thursday, June 25, 2015