|
From: | Paolo Bonzini |
Subject: | Re: [Help-smalltalk] (no subject) |
Date: | Mon, 15 Jan 2007 09:01:39 +0100 |
User-agent: | Thunderbird 1.5.0.9 (Macintosh/20061207) |
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
[Prev in Thread] | Current Thread | [Next in Thread] |