[comp.lang.smalltalk] finding instances

tony_mak_makonnen@cup.portal.com (06/21/87)

I am having trouble findind the names of instances I created under
Smalltalk/V . Is there a procedure that does that ? or must I document
every instance I create ? Any help appreciated .

wyant@apollo.uucp (Geoffrey Wyant) (06/22/87)

    > I am having trouble finding the names of instances
    > I created under Smalltalk/V.  Is there a procedure
    > that does this ? or must I document every instance
    > I create ?

    This is sort of like asking for the name of everything pointed
    at in C program.  Instances don't have names, per se.  Like
    pointers, they maybe assigned to variables or fields within
    records. If you just create them without assigning them
    to anything, they are inaccessible, just like a pointer to
    malloc'ed storage that you didn't assign to anything.  What 
    is it that you are trying to do ?  



 
-- 

Geoff Wyant   UUCP:  ...{yale,mit-eddie}!apollo!wyant

obrien@aero2.ARPA (Michael O'Brien) (06/24/87)

In article <359f3397.1d22@apollo.uucp> wyant@apollo.UUCP (Geoffrey Wyant) writes:
>
>    > I am having trouble finding the names of instances
>    > I created under Smalltalk/V.  Is there a procedure
>    > that does this ? or must I document every instance
>    > I create ?
>
>    This is sort of like asking for the name of everything pointed
>    at in C program.  Instances don't have names, per se.  Like
>    pointers, they maybe assigned to variables or fields within
>    records. If you just create them without assigning them
>    to anything, they are inaccessible, just like a pointer to
>    malloc'ed storage that you didn't assign to anything.

This points out something I have been noticing for some time: the
near-complete absence of any sort of general interactive (or even
batch!) tools for dealing with object memories.  [Presumably the
person in question is trying to delete a class.  You can't delete
a class, at least in DigiTalk Smalltalk, if it has instances.]

Berkeley Smalltalk (BS II) at least has a way to talk directly to
the VM and give it simple commands, outside of the Smalltalk environment.
One of these commands causes an integrity check of object memory - not
a bad idea in a research machine!  Xerox PS has no such facility.
Nor has any version of Smalltalk I've ever seen had any real tools
for characterizing the contents of object memory.  This person's
problem could be solved if there were some utility giving a chain
back to something understandable that appeared on the screen ("attached
to a window in Project foo" or "attached to This Window Here [big
flashing arrow]").

The UNIX environment is externalized completely: each object in it has
pretty much a directly accessible handle in some space (file names,
machine addresses, etc.).  This is not true in object memories...yet.
Now I'll grant that being able to depress this kind of stuff is the
whole and entire point of object-oriented programming!  However, if
you can't get hold of this kind of information AT ALL you may be up
the creek, like the person at the top of this message who kicked this
off.
-- 
--------
Mike O'Brien
obrien@aerospace.aero.org
aero!obrien

peterg@felix.UUCP (Peter Gruenbeck) (06/25/87)

In article <470@cup.portal.com> tony_mak_makonnen@cup.portal.com writes:
>I am having trouble findind the names of instances I created under
>Smalltalk/V . Is there a procedure that does that ? or must I document
>every instance I create ? Any help appreciated .

In the Digitalk Smalltalk you can execute:   Smalltalk inspect
which will open an inspector window on the system dictionary.
The system dictionary contains: classes, global variables (including
itself), and pool dictionaries. You can also send messages to the system
dictionary to search for senders and implementors of something.

Try 
     Smalltalk sendersOf: #at:
and
     Smalltalk implementorsOf: #at:

------------------------------------------------------
Poor grammar and spelling errors are included on purpose.
I print something for everyone.
and 

steele@unc.cs.unc.edu (Oliver Steele) (06/26/87)

In article <470@cup.portal.com> tony_mak_makonnen@cup.portal.com writes:
>I am having trouble findind the names of instances I created under
>Smalltalk/V . Is there a procedure that does that ? or must I document
>every instance I create ? Any help appreciated .

'MyClass allInstances' will return a collection of all instances of MyClass,
and 'MyClass allInstancesDo:' is the corresponding enumerator.  If you're
just looking for globals, use 'Smalltalk select: [ :instance | instance
class == MyClass]', and substitute 'Undeclared' or a pool name for
Smalltalk to look in the corresponding dictionary.

Something on the order of '(Smalltalk select: [:i|i class == MyClass])
inspect' is most convenient if you have a dictionary inspector.

------------------------------------------------------------------------------
Oliver Steele				  ...!{decvax,ihnp4}!mcnc!unc!steele
							steele%unc@mcnc.org

	"They're directly beneath us, Moriarty.  Release the piano!"

tony_mak_makonnen@cup.portal.com (07/01/87)

did I actually start this whole fuss about finding instances ?
All of a sudden it struck me that I could go the the change log
and sure enough there was a trace of everything I had done was right
there including the instance names . Granted I had to get out of
smalltalk and into dos to do it ! perhaps then it is still a problem

franka@mmintl.UUCP (Frank Adams) (07/02/87)

In article <699@unc.cs.unc.edu> steele@unc.UUCP (Oliver Steele) writes:
>In article <470@cup.portal.com> tony_mak_makonnen@cup.portal.com writes:
>>Smalltalk/V

>'MyClass allInstances' will return a collection of all instances of MyClass,
>and 'MyClass allInstancesDo:' is the corresponding enumerator.

Note that 'allInstancesDo:' is not implemented in Smalltalk/V.  You can
instead write 'MyClass allInstances do:', or you could implement an
'allInstancesDo:' method:
    allInstancesDo: aBlock
        self allInstances do: aBlock.
-- 

Frank Adams                           ihnp4!philabs!pwa-b!mmintl!franka
Ashton-Tate          52 Oakland Ave North         E. Hartford, CT 06108