Object.eq is ready for discussion
mjs at apple.com
Sun Sep 5 08:28:50 PDT 2010
On Sep 5, 2010, at 7:40 AM, Mark S. Miller wrote:
I think it's nearly mandatory, as the equivalence relation paired with Object.hashcode. A hash function is only meaningful in the context of an equivalence relation.
- Make Object.hashcode pair with === or == instead of Object.eq: formally impossible, because neither is actually an equivalence relation. Less formally, possible at the cost of making it impossible to use NaN as a hash key, or distinguish 0 from -0 as hash keys.
- Make Object.hashcode correspond to an equivalence relation that is described but not provided as a predefined function - now actually using hashcode becomes needlessly complicated and error prone.
It might even be desirable to name Object.hashcode something that makes the relationship to eq clear - Object.eqHash? On the other hand, it seems somewhat unlikely that other hash/equivalence pairs will be introduced to the standard, so maybe it doesn't matter.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss