> It's also disheartening to see that the sorted-set wants things that implement Java's Comparable.
Could you quickly explain what's disheartening about Java's Comparable interface and what the available options are?
> It's also disheartening to see that the sorted-set wants things that implement Java's Comparable.
Could you quickly explain what's disheartening about Java's Comparable interface and what the available options are?
Of course, in many implementations you usually also get a version of a constructor that uses a provided comparison function. However certain things, like plain numbers or strings, have a natural ordering to them, hence the need to have the sorted-set in Clojure also work with Java's Comparable. But again, I was expecting a Clojure specific protocol.
The reason for why this happens, I believe, is because protocols weren't there from the beginning, being a feature introduced in Clojure 1.2. From what I understood, in ClojureScript protocols are "at the bottom" as they say, so there's hope :-)
OTOH it’s not often I’ve seen third-party types that I wanted to be comparable but were not. In general I think that if a type does not implement a core interface you have to consider the possibility that the designer chose not to implement it for a reason.
=> (sorted-set-by - 2 9 3 5 4) #{2 3 4 5 9}