On Oct 3, 10:40 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Oct 3, 2008, at 9:50 AM, Paul Barry wrote:
>
> > The fact that contains? is semantically different than
> > java.util.Collection#contains is confusing.  If contains? was called
> > contains-key?, that would be more intuitive and map to how it works in
> > Java.
>
> Several times I've made the mental note: when I see contains? I need
> to think contains-key?. I think changing the name to contains-key?
> would make the meaning very clear.
>

I'm not sure it's that clear cut. For instance, Clojure contains? maps
semantically and namewise to java.util.Set.contains, as it also works
for Clojure sets.

Collection.contains was always a bad idea, having indeterminate
performance.

> Also, if you're dealing with values that are known not to be false or
> nil (which I suspect is a common case), (contains? m k) is equivalent
> to (m k). Typing the extra "-key?" seems worth it for its clarity in
> the "false or nil is possible" case.
>

I don't think contains-key? works for sets or vectors very well, and
am not inclined to change this much-used name to this, since I'm
unlikely to want contains? for anything else, certainly not
questionable-performance generic collection value containment.

Rich

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to