Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!europa.chnt.gtegsc.com!howland.reston.ans.net!agate!news.mindlink.net!vanbc.wimsey.com!fonorola!news!dbuck
From: dbuck@infoweb.magi.com (David Buck)
Subject: Re: Object identifiers.
Sender: news@magi.com
Message-ID: <DBF9oJ.B86@magi.com>
Date: Sun, 9 Jul 1995 00:07:31 GMT
References: <3tjrmu$gr6@duf.ifi.uio.no>
Nntp-Posting-Host: infoweb.magi.com
Organization: Magi Data Consulting
Lines: 29

In article <3tjrmu$gr6@duf.ifi.uio.no>, Urban Klock <kjelll@ifi.uio.no> wrote:
>
>I have digged through the PP user's guide,but find nothing
>about using Oid's directly.
>Is this incidental, or should direct use of Oid's be avoided
>for some reason?

Basically, in Smalltalk there's no such thing as an OID.  The closest 
thing to it is the address of the object's pointer in the object table 
but this information isn't available to Smalltalk.

The root question, therefore, is what can you do with an OID (which is 
just a number) that you couldn't do with the object itself?  If you did 
have an OID, you would use it as a key in a dictionary perhaps.  Well, if 
you use an IdentityDictionary, you could use the object itself instead.  
Having an OID for it doesn't buy you any advantage.

I've often found it useful when debugging to determine if an object shown 
in one inspector is the same instance as the one shown in another 
inspector.  In cases like this, I send 'self identityHash' to the objects 
in each inspector.  The identity hash numbers aren't guaranteed to be 
unique but they give you a 1 in 16,384 chance of getting the same hash 
for a different instance.  I'd never depend on this in code, however.  
Using == tests is all I need.

David Buck
dbuck@magi.com
The Object People

