FAQ
Hi,

I heard Rich Hickey talking about how identity in clojure is synonymous
with value-based tests of equality. To make this efficient he describes
that objects store cached hashes that are used to speed up these tests of
equality, so clojure isnt comparing every data member of a complex data
structure. However, how does this actually work since a comparison of
hashes doesn't guarantee that two objects are equal. How does clojure
handle the case where two hashes are the same for two distinctly different
values.

Andy

--
--
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+unsubscribe@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Cedric Greevey at Nov 28, 2013 at 10:51 pm
    Presumably it then compares the objects element by element. If the common
    case is for the arguments to (= x y) to be unequal with unequal hashes,
    though, this is still considerably faster.

    On Thu, Nov 28, 2013 at 5:03 PM, Andy Smith wrote:

    Hi,

    I heard Rich Hickey talking about how identity in clojure is synonymous
    with value-based tests of equality. To make this efficient he describes
    that objects store cached hashes that are used to speed up these tests of
    equality, so clojure isnt comparing every data member of a complex data
    structure. However, how does this actually work since a comparison of
    hashes doesn't guarantee that two objects are equal. How does clojure
    handle the case where two hashes are the same for two distinctly different
    values.

    Andy

    --
    --
    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+unsubscribe@googlegroups.com
    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 unsubscribe from this group and stop receiving emails from it, send an
    email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    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+unsubscribe@googlegroups.com
    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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Mark Engelberg at Nov 28, 2013 at 10:54 pm
    If two objects are identical (actually point to the same slot in memory),
    they can immediately be determined to be equal.

    There are also some ways to quickly determine that things are definitely
    not equal. For example, two vectors with different sizes are not equal.
    As you've pointed out, if the hashes of two objects are different, one can
    potentially quickly conclude that the two objects are not equal, but the
    Clojure code currently is somewhat inconsistent about applying this test.
    I think this inconsistency is because cached hashes are a relatively recent
    addition, and it hasn't quite percolated through to all the places that
    could take advantage of this.

    If the objects are different and the hashes are the same, you still have to
    compare the entire structures to be certain they are equal.

    On Thu, Nov 28, 2013 at 2:03 PM, Andy Smith wrote:

    Hi,

    I heard Rich Hickey talking about how identity in clojure is synonymous
    with value-based tests of equality. To make this efficient he describes
    that objects store cached hashes that are used to speed up these tests of
    equality, so clojure isnt comparing every data member of a complex data
    structure. However, how does this actually work since a comparison of
    hashes doesn't guarantee that two objects are equal. How does clojure
    handle the case where two hashes are the same for two distinctly different
    values.

    Andy

    --
    --
    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+unsubscribe@googlegroups.com
    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 unsubscribe from this group and stop receiving emails from it, send an
    email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    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+unsubscribe@googlegroups.com
    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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupclojure @
categoriesclojure
postedNov 28, '13 at 10:03p
activeNov 28, '13 at 10:54p
posts3
users3
websiteclojure.org
irc#clojure

People

Translate

site design / logo © 2022 Grokbase