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

Ronald Spengler ron.spengler at gmail.com
Wed Aug 19 04:41:35 UTC 2009


Familiar with hashes. Grok it; I can use it to see if two objects are the
same object or not, and looking for a particular object by it's hash is
probably expensive.
Thank you:)

On Tue, Aug 18, 2009 at 9:38 PM, Michael van der Gulik <mikevdg at gmail.com>wrote:

>
>
> On Wed, Aug 19, 2009 at 4:19 PM, Ronald Spengler <ron.spengler at gmail.com>wrote:
>
>> When I (for example,) in a workspace, Command-P the text 'morph3874 color:
>> Color red' and see 'aMorph(2413)', what does the number mean? I'm guessing
>> it's some kind of object pointer. An OOP perhaps, I've heard people speak of
>> those? This has been bugging me for a year, and I can't seem to construct a
>> Google string that finds me an answer to the question. Can I use that number
>> to find the object in the object memory?
>> Why I ask:
>>
>> I'm presently trying to understand...
>>
>> http://bugs.squeak.org/bug_view_page.php?bug_id=456
>>
>>
> Look at the code in Morph>>printOn:
>
> Morph>>printOn: aStream
>     | aName |
>     super printOn: aStream.
>     (aName := self knownName) notNil
>         ifTrue: [aStream nextPutAll: '<' , aName , '>'].
>     aStream nextPutAll: '('.
>     aStream
>         print: self identityHash;
>         nextPutAll: ')'
>
> This gets called when you do alt-p on a morph in a workspace. The
> second-to-last line is of interest; this is the number that you're seeing.
> It's an "identityHash". I'm not going to explain hashing here; Wikipedia can
> teach you more if you're curious.
>
> If you look at the implementation of ProtoObject>>identityHash, it is
> primitive 75. If you look at the implementation of Object>>asOop, it is also
> primitive 75. So, coincidentally, yes, it is an OOP (object pointer).
>
> The intention however was just to print out a number that is unique for
> each different instance so that you can see whether two variables are
> pointing to the same morph. This is useful for debugging. In my own images,
> I often modify printOn: methods to print out hashes or oops for the same
> reason.
>
> I'm not sure how you'd convert an oop to an object. I guess you could
> search through all objects in the image looking for the right one.
>
> Gulik.
>
> --
> http://gulik.pbwiki.com/
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20090818/868e6918/attachment.htm


More information about the Squeak-dev mailing list