In this case, a good question could be "are 0 and nil the same?"
In some languages like C or C++, NULL and 0 are the same (at least, for x86 Intel architecture, I don't know for others). You find some old code where you have ptr == 0 instead of ptr == NULL. And often, you have test for pointers like if (ptr) { .... }.

Perhaps a study of JVM would tell what is null.



On 12/21/2012 09:10 PM, [email protected] wrote:
I think the intial post was not about the fact that collision was a problem but about the fact that 0 and nil are frequent elements, so using the same hash (if there is no good reason) would result in many useless collisions.

However, there might be a good reason to have nil and 0 having the same hash.
(nil must probably have a hash equal to '() for example)


On Fri, Dec 21, 2012 at 9:05 AM, Christian Sperandio <[email protected] <mailto:[email protected]>> wrote:

    I write again my post because the previous was bad written and I
    want to respect the Englis language the more as I can.
    With your question, I'm feeling you think each item has a
    different hash code. But it's wrong. You can meet collisions.
    An hash code is not an id, it's a way to find an element.
    So even if it's weird to have the same hash code for 0 and nil,
    this case is useful because it's shown you a case of collisions.


    Le jeudi 20 décembre 2012 19:04:06 UTC+1, Stathis Sideris a écrit :

        Hello,

        I noticed the following:

        > (hash 0)
        0
        > (hash nil)
        0

        Which is fair enough I suppose. It seems to have the following
        side-effect though:

        > (hash [1 2 3 0])
        955327
        > (hash [1 2 3 nil])
        955327

        Is that the intended behaviour? I suppose it's OK for two
        things to hash to the same value, but IMHO, it would make the
        hash function more useful to avoid this simple case. The
        implementation seems to check for nil specifically and to
        return 0.

        Thanks,

        Stathis

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




--
Sent from an IBM Model M, 15 August 1989.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your first post.
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

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
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