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

21

u/vvvvalvalval Mar 18 '21

I'll still refrain from designing functions that way, and would encourage people to do the same.

Compared to keyword-varargs, an optional map argument costs at worst one more keystroke to invoke, and it's simply a more straightforward and regular behaviour to build on top of.

I suspect that most of the Clojure APIs out there which use keyword varargs did so by imitation of Python and just overlooked the alternative of using a map argument, or really had an unsound obsession with concision.

1

u/[deleted] Mar 19 '21

Ok good it's not just me. I don't see any value in this feature.

Edit: it is nice when forced to deal with someone else's varargs function that should have just taken a single map. But just within my own code, I shouldn't need this at all.