Extra optional attr-map argument on defn... why?

77 views
Skip to first unread message

Robert Levy

unread,
Aug 9, 2021, 12:33:36 AM8/9/21
to clo...@googlegroups.com
In a private chat (I will not expose their names, but they may feel free to identify themselves in this thread) someone posed a question:

Anyone know why the multi-arity version of `defn` takes an extra optional `attr-map?` argument? https://github.com/clojure/clojure/blob/clojure-1.10.1/src/clj/clojure/core.clj#L290

Someone in the chat offered:

I am sure someone wanted to do (->> {:more :metadata} (defn ... )) and fixed the issue right there.

Someone else in the chat did some detective work and this is what she came up with:

* defn went from a simple form that could only create single arity definitions to the current multiple-arity definitions, and when it did this, it introduced the metadata options. Back then, all of this was in src/boot.clj. The checkin was 23df286 on Mar 7, 2008 https://github.com/clojure/clojure/commit/23df28671fe46d4a39d2aadc36262c9dae1f406a
* Rich updated defn in 2009 and it was in there prior to that.
* Alex added the extra arglists entry that describes it in 2011.

So the multiple attr-map? values have been around since attr-maps were first introduced. No explanation why

Anyone know why?
Reply all
Reply to author
Forward
0 new messages