[squeak-dev] true hash ^20

Bert Freudenberg bert at freudenbergs.de
Thu May 10 10:27:53 UTC 2012


On 09.05.2012, at 23:04, Chris Cunnington wrote:

> Thinking about it, a hash is a part of a header of an object used to give an object a unique identity.

Not quite. It's only a number that is guaranteed to be constant across the live time of the object. It does not uniquely identify the object:

(SystemNavigation default allObjectsSelect: [:obj | obj identityHash = nil identityHash]) size

==> more than 400 in my image.

>  nil, true, and false have a single instance per image. There is only one in the image for each and it's in ObjectMemory.
> 
> 2.7 InterpreterSimulatorLSB
> 
> ObjectMemory>>nilObj  4
>                          falseObj 12
>                          trueObj 20

In the real interpreter nil, false, and true are simply the first three entries in the specialObjectsArray. The OOP of the specialObjectsArray is stored in the image header. That is how the VM finds and knows these objects. For quicker access, their OOPs are cached in global variables. See #initializeObjectMemory:.

- Bert -

> 

> You cannot make two instances of nil. For the VM, which is all about numbers, and not really about classes, it will say "Is this object #4? Yes? It's nil"
> 
> 
> nil hash 1681
> 
> nil hash 1681
> 
> nil == nil true
> 
> x := SystemTracer new hash 1136
> 
> y := SystemTracer new hash  394
> 
> x == y false
> 
> You could say that Chris is a class. And there are many instances of Chris. The last names Muller and Cunnington are the hash.
> 
> Chris == Chris false
> 
> I'm glad you asked this question. It made me think.
> 
> Chris
> 
> 
> 
> 
> 
> 
> 



More information about the Squeak-dev mailing list