>>>>> "J" == Jacob Fugal <lukfugl / gmail.com> writes:

> So the primary reason eql? is separate from == is that eql? needs to
> be sure to follow hash. So now my question is: why isn't the default
> implementation of eql? to compare hash instead of object_id? Then we
> can override hash in cases where we want to, and not need to worry
> about eql? unless we really need to...

Hashes values don't have to be unique.  Two distinct values may return
the same hash code, but should return false for eql?.  Remember how hash
tables work from CS class -- if two hash codes are the same, the table
chains the values together in a linked list under the same hash
'bucket'.  To retrieve a value it first finds the relevant hash bucket
via #hash, and then walks through the list sequentially using #eql? to
compare.  So #eql? had better return false for two distinct values.  On
the other hand, 'def hash; 1; end' is a perfectly correct albeit very
inefficient #hash implementation.

Steve