# Why is it stated that metadata is a property of symbols?

**URL:** https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917
**Category:** General Questions
**Created:** [September 30, 2019, 2:35pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917 "2019-09-30T14:35:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Dziadzka](https://clojureverse.org/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@Dziadzka](https://clojureverse.org/u/Dziadzka)
#### Post date: [September 30, 2019, 2:35pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/1 "2019-09-30T14:35:04Z")

</div>

…when it is contradicted by _meta_ function usage:

```
(def ^:metadata X 0)    
(meta 'X) => nil
(meta #'X) => {:metadata true, ...

```

Both clojure.lang.Var, and clojure.lang.Symbol support IMeta interface, but apparently def-ing attaches metadata to the former.

_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._ - from [clojure.org](http://clojure.org)

Am I missing some technical, or philosophical detail here?

---

<div class="post-metadata">

### Author: ![borkdude](https://clojureverse.org/user_avatar/clojureverse.org/borkdude/32/306_2.png) [@borkdude](https://clojureverse.org/u/borkdude)
#### Post date: [September 30, 2019, 2:55pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/2 "2019-09-30T14:55:26Z")

</div>

`def` is a special form and its syntax allows to add metadata on the var your are creating. It does not attach that metadata also to the value. Typical metadata fields attached to a var are `:docstring`, `:private` and/or `:macro`. If you want to add metadata to the value that the var is pointing to, e.g. a symbol, you can do that with `with-meta`, `vary-meta`, etc.:

```auto
(-> 'foo (with-meta {:a 1}) meta)
{:a 1}

```

I use that feature a lot in [clj-kondo](https://github.com/borkdude/clj-kondo). Not all values can carry metadata, for examples strings and keywords cannot.

---

<div class="post-metadata">

### Author: ![Dziadzka](https://clojureverse.org/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@Dziadzka](https://clojureverse.org/u/Dziadzka)
#### Post date: [September 30, 2019, 3:24pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/3 "2019-09-30T15:24:31Z")

</div>

Yes, I see, as I mentioned clojure.land.Symbol supports IMeta, so surely a symbol can carry metadata. My question is more about why [clojure.org](http://clojure.org) insists on symbol-metadata relationship omitting that of var-metadata in spite of the fact it is clearly present in idiomatic usage (def). I’m trying to find a hidden meaning in the wording, though I’m not sure it exists 🙂

---

<div class="post-metadata">

### Author: ![borkdude](https://clojureverse.org/user_avatar/clojureverse.org/borkdude/32/306_2.png) [@borkdude](https://clojureverse.org/u/borkdude)
#### Post date: [September 30, 2019, 4:18pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/4 "2019-09-30T16:18:16Z")

</div>

I’m not sure, but reasons the metadata is not duplicated onto the value as well, could be:

- not really needed in practice, having it in one predicable place is sufficient
- duplication leads to data going out of sync
- not all values can take metadata

This is just me guessing :).

---

<div class="post-metadata">

### Author: ![alexmiller](https://clojureverse.org/user_avatar/clojureverse.org/alexmiller/32/4805_2.png) [@alexmiller](https://clojureverse.org/u/alexmiller)
#### Post date: [September 30, 2019, 6:18pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/5 "2019-09-30T18:18:26Z")

</div>

The missing bit in the [clojure.org](http://clojure.org) docs is probably just an oversight.

Re vars - `def` is a special form to make vars, and it thus makes sense for the meta you supply to be attached to vars (as that’s what def makes). The symbol here is just used as a key internally in namespace state, it doesn’t really make sense to attach the metadata to the symbol. Other symbol makers may want different metadata when they make their symbol. And the value referred to by the var is independent and may have different metadata - you can attach it there as well (when it’s appropriate).

In summary, the var, symbol, and value are all different entities with different uses and constraints.

---

<div class="post-metadata">

### Author: ![borkdude](https://clojureverse.org/user_avatar/clojureverse.org/borkdude/32/306_2.png) [@borkdude](https://clojureverse.org/u/borkdude)
#### Post date: [September 30, 2019, 6:31pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/6 "2019-09-30T18:31:16Z")

</div>

Now I see I completely misunderstood the issue and interpreted it as the metadata going on the the value that is contained in the var… LOL, sorry.

---

<div class="post-metadata">

### Author: ![Dziadzka](https://clojureverse.org/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@Dziadzka](https://clojureverse.org/u/Dziadzka)
#### Post date: [September 30, 2019, 7:39pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/7 "2019-09-30T19:39:10Z")

</div>

No prob, happens to the best of us 🙂

---

<div class="post-metadata">

### Author: ![Dziadzka](https://clojureverse.org/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@Dziadzka](https://clojureverse.org/u/Dziadzka)
#### Post date: [September 30, 2019, 7:40pm UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/8 "2019-09-30T19:40:09Z")

</div>

Thanks, Alex! Makes sense. I probably overthought this stuff.

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [March 31, 2020, 7:40am UTC](https://clojureverse.org/t/why-is-it-stated-that-metadata-is-a-property-of-symbols/4917/9 "2020-03-31T07:40:15Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
