If the value of
      receiver == comparand
   is true then the receiver and comparand must have equivalent
   identity hash values. Or more formally:
      receiver == comparand ==>
         receiver identityHash = comparand identityHash

This is not an "if and only if". If two objects have the same identityHash you cannot conclude that they are identical. In GNU Smalltalk "x identityHash identityHash == x identityHash" in particular, so every object's identityHash will collide with exactly one integer's identityHash.

Also note that "51546 asOop" is an error, while "51546 identityHash" is the integer 51546 itself.

In the other case, (123/3) is the integer 41 rather than the fraction (41/1), so

  123 / 3 identityHash = 123 / (3 identityHash) = 123 / 3 = 41
  (123 / 3) identityHash = 41 identityHash = 41
  (123 / 3) asFraction identityHash = (41/1) identityHash = an object index
                                      ^^^^^^
           this represents a Fraction object, not the value of 41/1

Paolo


_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to