Why set identity of #becomeForward: argument to the receiver?

Raab, Andreas Andreas.Raab at disney.com
Thu Jul 29 23:49:09 UTC 1999


> The upshot of this is if I had created an IdentityDictionary before the
> #becomeForward, such as
> 
>     (C := IdentityDictionary new)
>         at: A put: 1;
>         at: B put: 2.
> 
> Then after the #becomeForward: I find
>     (C at: A) = 1
>     (C at: B) = 1
> 
> I would have imagined that after the #becomeForward: that A would now take
> the original #identityHash value of B.  So
> 
>     (C at: A) = 2
>     (C at: B) = 2
> 
Well - first of all, after the #becomeForward: operation you'll have two
identical keys in the Dictionary (meaning that your Dictionary is screwed up
anyways). Whose's value you'll get depends on what is found first in the
Dictionary; and if there has been any collision between A and B before you
did your #becomeForward: operation you'll get the value of the first (which
is '1' in your above example) since that association is in the right place
for the key. If there hasn't been a collision you should get the value of
the second one - so just have your code run often enough and you'll get
different results.

BTW, how do proxies deal with this issue?! Do they generally keep an ID hash
for the external object around?!

  Andreas
--
+===== Andreas Raab ========= (andreasr at wdi.disney.com) ==+
| Walt Disney Imagineering        Phone: +1 818 544 5016  I
I Glendale, CA                    Fax:   +1 818 544 4544  I
+======< http://isgwww.cs.uni-magdeburg.de/~raab >========+





More information about the Squeak-dev mailing list