Thanks as ever for Clojure- we love it, and use it all day every day to solve worthy problems in ways that delight us as programmers and wow our users as well.
I was naively taking set differences, hoping for this, and was pleased:
> (clojure.set/difference #{:a :b :c} '(:a 1 2))
#{:c :b}
Then I did this, and was surprised:
> (clojure.set/difference #{:a :b :c} '(:a 1 2 3))
Execution error (IllegalArgumentException)
contains? not supported on type: clojure.lang.PersistentList
Then I read the implementation of clojure.set/difference
, and I get it now:
https://github.com/clojure/clojure/blob/a29f9b/src/clj/clojure/set.clj#L49-62
But, I do wonder if it would be funner if this just worked. And since funner is probably a more important criteria to me than it is to you, I wonder what the real tradeoffs are here.
- Is it performance?
- Or, what would be the downside of implicitly converting to something that implements
contains?
at the critical moment?