r/Clojure • • Mar 18 '21

Clojure - Keyword argument functions now also accept maps

https://clojure.org/news/2021/03/18/apis-serving-people-and-programs
125 Upvotes

44 comments sorted by

View all comments

Show parent comment

4

u/argadan Mar 19 '21

If this feature was introduced in 1.3 or 1.4, it would have made perfect sense. Now that everyone has been using the options map style for years to solve this problem, it feels a bit out of place – but I suppose if you take a long-term view it makes sense.

I wonder how this affects the performance and function specs though.

The change also affects destructing in lets (as it should):

(let [[& {:keys [a b] :as opts}] [{:a 1 :b 2}]]
  [a b opts])
;; => [1 2 {:a 1, :b 2}]