On Jun 4, 2012, at 5:49 PM, Meikel Brandmeyer wrote:

>> Does anyone else think this is bad behavior, or should I ensure the map 
>> isn't sorted before asking it if it contains a key?
> 
> The problem is not asking the sorted-map for contained keys but the keys you 
> use. You can't compare numbers to keywords. You probably have to provide your 
> own comparator if you need to mix numbers with keywords.

Right, and in my trivial example it's easy to say that I shouldn't use a 
keyword when the map is sorted on integers. However, in my prod code the map 
may be sorted, by any comparator, or it may just be a standard map. It's a 
library, and I can't always know what the map will contain or whether or not 
it's sorted. I can solve the issue with (and (not (sorted? x)) (contains? x 
:a)) for my specific case, but I'm asking if in general it makes sense for a 
sorted map to throw an exception when it's asked for a key that would cause the 
comparator to exception.

The exception surprised me, but perhaps I expect too much.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to