John Harrop wrote: > Probably the seq .hashCode should consider only the first N elements > for some maximum N and if two longer (or even infinite) sequences > collide so be it.
I strongly disagree. Choosing some arbitrary magic cutoff point just seems cause for trouble and much confusion. Putting something in a hash set or using it as a map key implies evaluating it -- you'd expect summing or printing an infinite sequence to hang, so why shouldn't hashing it also hang? Also to those suggesting treating infinite sequences differently to regular ones: it's impossible to determine (in the general case) whether a sequence is infinite or not as it would involve solving the halting problem. Throwing an exception in some specific cases would require changing things like (repeat x) to use a different seq implementation class. I think this would gain you very little since there's only a couple of cases where this can be done and as soon as you do something with the seq you don't know whether it's infinite anymore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---