get instance using the hash value?

Richard A. O'Keefe ok at atlas.otago.ac.nz
Mon May 28 05:28:32 UTC 2001


	An object has a hash value (self hash).
	
	1.    How can I get hold of an object with its hash value?
	      anInstance _ AClassCanCreateInstanceUsingHashValue hash: 2340
	
It is in the nature of hash codes that they are not unique.
There could be many thousands of objects with that hash code.
Hash codes are not pointers, they're just a hack to speed up table lookups.

I haven't checked:  does Squeak 3.x still use 12-bit hash codes?

	2.    If I can get hold of an instance, how can I destroy it?
	
Unseemly hacking in the VM aside, you can't.
Smalltalk objects can survive anything except the death of (their) universe
and insufficient attention.  If you stop looking at them, they pine away.

What you _can_ do is hunt down variables holding references to an object and
nil them out, whereupon the object will eventually pine away because
no-one is interested any more.

What is the application problem you are trying to solve by these means?





More information about the Squeak-dev mailing list