[squeak-dev] Re: Newbie Question (about OOPs, maybe) (sorry)

David T. Lewis lewis at mail.msen.com
Sun Aug 23 15:52:25 UTC 2009


On Sun, Aug 23, 2009 at 04:36:24PM +0200, Bert Freudenberg wrote:
> On 23.08.2009, at 11:42, Trygve Reenskaug wrote:
> >On 2009.08.22 17:26, Bert Freudenberg wrote:
> >>On 22.08.2009, at 12:39, Trygve Reenskaug wrote:
> >>>In short:
> >>>	? Smalltalk claims to be object oriented and I regard it as a  
> >>>serious flaw that the object ID is not explicitly visible.
> >>
> >>What if there simply *is* no object ID?
> >In Smalltalk, a value is a pointer to an object. Bluebook p. 564:  
> >"Each object is associated with a unique identifier called its  
> >object pointer. ..."
> 
> ... digs out Blue Book ...
> 
> Yes. This is the VM implementation chapter. IMHO it does not mean an  
> OOP has to be accessible from the image as an integer.
> 
> >Smalltalk MUST have such unique identifiers to work. I see this  
> >pointer as the object's ID. I have seen from the discussion in this  
> >track that the VM can actually change this "unique" pointer.
> 
> The VM can do anything as long as you can't tell from the image. And  
> you can't. OOPs cannot be accessed directly.

To illustrate the current behavior in Squeak, I used a plugin that
displays OOP values, addresses, etc. Thus:

  (1 to: 100) do: [:e | Array with: e]. "make some garbage"
  aString := 'Hello there'. "allocate an object"
  aString asOop. => 1422 "identity hash for the object"
  OopPlugin oopPrintStringHex: aString. '16r0FF3BE64' "current OOP value"
  OopPlugin machineAddressPrintStringHex: aString. '16r00002B66BBE8AE54' "C pointer to object header"
  Smalltalk garbageCollect. "cause objects to move around in the object memory"
  aString asOop. => 1422 "identity hash remains the same"
  OopPlugin oopPrintStringHex: aString. => '16r0FF36954' "OOP value has changed"
  OopPlugin machineAddressPrintStringHex: aString. => '16r00002B66BBE85944' "object has moved"

The OOP is a unique identifier for the object at a particular instant in
time, but the VM is free to change it at any time without telling you.

Dave




More information about the Squeak-dev mailing list