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

Adrian Lienhard adi at netstyle.ch
Sat Aug 22 11:15:54 UTC 2009


Oh, don't use asOop. It is useless as an OID as it changes as soon as  
the GC moves the object in memory... Pointer here really means a C  
pointer.

#identityHash has only a size of 12 bits and hence is quite a weak  
hash and useless for an OID.

In short, the concept of an object ID does not exist (unless, of  
course, you implement it yourself).

Cheers,
Adrian

On Aug 22, 2009, at 12:39 , Trygve Reenskaug wrote:

> Hi All,
> IMO, every object has three essential properties: Identity, State,  
> and Behavior. In Smalltalk, State and Behavior are defined by the  
> object's flattened class hierarchy. The Object ID is not explicitly  
> available. I have am using 'asOop', hoping I  get a unique value.  
> But I realize that I am skating on thin ice because its comment  
> confuses me with implementation details. It doesn't say what it  
> means by 'pointer', so there is still hope:
>
> /Object>>asOop
>   "Primitive. Answer a SmallInteger whose value is half of the  
> receiver's
>   object pointer (interpreting object pointers as 16-bit signed  
> quantities)..."/
>
> /ProtoObject>>identityHash
>   "Answer a SmallInteger whose value is related to the receiver's  
> identity..."
> /This is pretty vague, but the term 'Hash' indicates that many  
> objects can share the same value. So it is clearly cannot be used as  
> the objectID.
>
> The Morph>>printOn: implementation is less than ideal because it  
> should apply to all objects, not only Morphs. Also, it should use  
> 'asOop' rather than 'identityHash' to let us hope for uniqueness.
>
> In short:
>
>   * Smalltalk claims to be object oriented and I regard it as a
>     serious flaw that the object ID is not explicitly visible.
>   * We probably need a 64-bit VM to represent it properly, e.g., using
>     the standardized definition of OID, but a value that is guaranteed
>     to be unique within the current set of objects would be  
> acceptable..
>   * I regard it as a bug that Object>>printOn: does not present some
>     kind of object ID.
>
> Cheers
> --Trygve
>
>
> On 2009.08.20 06:37, K. K. Subramaniam wrote:
>> On Wednesday 19 Aug 2009 11:07:29 am Ronald Spengler wrote:
>>
>>> Ah, so the GC in the VM swizzles the pointers out from under you.
>>> http://lists.squeakfoundation.org/pipermail/squeak-dev/1999-June/006170.htm
>>> l
>>>
>>>
>> This is the classic dilemma between name as an identifier and name  
>> as a locator. The word "pointer" connotes the latter but gets used  
>> widely in the former sense in Smalltalk code. Object Identifier  
>> (oid) is unambiguous but doesn't sound half as cool as oop ;-).
>>
>> Subbu
>>
>>
>>
>>
>
> -- 
>
> Trygve Reenskaug       mailto: trygver at ifi.uio.no
>
> Morgedalsvn. 5A         http://heim.ifi.uio.no/~trygver
>
> N-0378 Oslo               Tel: (+47) 22 49 57 27
>
> Norway
>
>




More information about the Squeak-dev mailing list