Luke VanderHart wrote:
> On Oct 29, 4:01 am, Mark Engelberg <mark.engelb...@gmail.com> wrote:

>> I see your point that hashCode could be made to work on infinite
>> sequences, but since hashing is almost always a prelude to testing for
>> equality, I'm hard pressed to think of an example of why you'd want to
>> be able to do this.  Can you illustrate with an example?

> Wouldn't hashCode be called every time you use an infinite sequence as
> a key in a hash map?

Yes, but this is another case where hashing is a prelude for testing 
equality.  If there's a hash collision then the map will have to use 
equality testing to distinguish between two keys.  If you make hashCode 
always work on infinite sequences, then sometimes using them as keys in 
maps will work and other times -- seemingly randomly -- it won't.  In my 
opinion this is much worse than them never working as map keys.

> That strikes me as a problem, since everything else in Clojure makes
> perfectly good map keys.

"Everything else" in Clojure is also printable and equality testable in 
finite time.  There's just some things you can't do reliably with 
infinite sequences.

--~--~---------~--~----~------------~-------~--~----~
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