Fork me on GitHub
#clojure-spec
<
2021-02-13
>
vlaaad13:02:09

I was playing with built-in specs and discovered there are A LOT of places to embed var metadata in defn:

(defn ^{:b 1} foo
  {:c 1}
  ([])
  {:a 1})
:a , :b and :c all end up in var meta!

vemv15:02:58

> I wonder how's that I guess it's because if there was just one place, people could accidentally place it elsewhere and get no metadata attached

vlaaad13:02:30

I wonder how's that, and why :arity-n defn variation allows attr map at the end...

Alex Miller (Clojure team)16:02:22

I found that when I spec’ed it and asked Rich about it. The thought at the time was that metadata might get big (this predated some of the ^ syntax) and it would obscure the main part of the function so you could put it at the end

Alex Miller (Clojure team)16:02:54

It’s rarely used but I did find some places using when testing a spec without it

vlaaad19:02:13

Very interesting, thanks for this explanation!