[Mono-list] mcs compiles on linux. Now what?

Miguel de Icaza miguel@ximian.com
07 Mar 2002 21:15:53 -0500


   Piers, thanks for forwarding those bits of information to the list:

> Yes, Object.GetHashCode() must be based on immutable instance values
> (otherwise you lose objects in hashtables). But the kicker is that if
> Object.Equals() returns true then the two object's GetHashCode()s _must_
> be the same !!!

This problem is not only a problem with the .NET framework
implementation, it is a problem in general of Hashtables, and you must
be aware of this at all times.

Basically, when you ever change the state on which the hash code for the
object is going to depend, you need to remove the object, change the
state, and re-add the object (You can see Gnumeric doing this for
example for Cells in the spreadsheet when they were moved or copied to a
new location). 

Its funny that you do mention this, because over the past few months I
literally have got worried about this by no apparent reason, I would be
walking somewhere and think `Oh my god, that piece of code is mutating
an object and not moving it'.