Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't clojure sets accept a default argument?

Tags:

clojure

Why do maps and keywords both have an extra arity with a default argument, while sets don't?

Is this an implementation detail, or a specific design decision?

({:a 2} :b :not-found) ;;=> :not-found

(:b {:a 2} :not-found) ;;=> :not-found

;; This seems counter intuitive.
(#{:a} :b :not-found) ;;=> clojure.lang.ArityException

(:b #{:a} :not-found) ;;=> :not-found
like image 212
madstap Avatar asked Jul 18 '16 16:07

madstap


1 Answers

I don't think there's any compelling reason: they certainly could, and it seems reasonable enough to me. The feature was added for maps and keywords in 3b7c1612, and hasn't been touched since; I guess it just wasn't included in that initial commit and there's been no great reason to revisit that decision since.

like image 126
amalloy Avatar answered Nov 15 '22 09:11

amalloy