[squeak-dev] Re: Newbie Question (about OOPs, maybe) (sorry)
Trygve Reenskaug
trygver at ifi.uio.no
Sat Aug 22 10:39:51 UTC 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090822/e9332bc1/attachment.htm
More information about the Squeak-dev
mailing list
|