krubin@gitpyr.UUCP (02/08/87)
This is a question concerning the use of the Smalltalk/V
package put out by Digitalk.
QUESTION: how does one determine the names of instances that
have been created for a given class by application
of the 'new' method selector?
PROBLEM: when I make a modification to a given class, i.e.,
add/remove a new instance or class variable, I cannot
save the modification (from the ClassHierarchyBrowser).
Attempting to do so results in a window popping up that
says "Has Instances". The solution to the problem seems
to be to find all instances of the class (or subclass)
and set them equal to something other than an object of
the class I am trying to modify. Unfortunately, I can't
seem to be able to locate the names, and more so, who
is using them (containing the names).
MISC: I can offer the following information about the problem:
1) In class Behavior there is a method names "allInstances"
According to the Programming Handbook, this returns an
array of all the instances of the receiver. When I send
this selector to a class name, I get back an array of the
of classNames and not the instances names of the class.
form #(a className a className...). Thus I get an array
of classNames rather than the names of the instances of
the class.
2) I have used the inspect selector to examine the Smalltalk
systemDictionary. However, this does not provide the
information I need.
3) So many other tests that I won't bother to list them.
I would sure appreciate any help on this issue. We are implementing
a fairly substantial modeling system (expert system) and problems
like this are killing our schedule.
Thanx in advance.
<---------------------------------------------------------------------->
Kenneth S. Rubin (404) 894-2348
Center for Man-Machine Systems Research
School of Industrial and Systems Engineering
Georgia Institute of Technology
Post Office Box 35826
Atlanta, Georgia 30332
Majoring with: School of Information and Computer Science
...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!krubin
<-------------------------- LINE EATER'S FOOD ------------------------->rentsch@unc.UUCP (02/15/87)
In article <3060@gitpyr.gatech.EDU> krubin@gitpyr.UUCP (Kenny Rubin) writes: > QUESTION: how does one determine the names of instances that > have been created for a given class by application > of the 'new' method selector? > > PROBLEM: when I make a modification to a given class, i.e., > add/remove a new instance or class variable, I cannot > save the modification (from the ClassHierarchyBrowser). > Attempting to do so results in a window popping up that > says "Has Instances". The solution to the problem seems > to be to find all instances of the class (or subclass) > and set them equal to something other than an object of > the class I am trying to modify. Unfortunately, I can't > seem to be able to locate the names, and more so, who > is using them (containing the names). From the way you describe the problem I would guess that you are somewhat confused about the details of objects and how they are referenced (in particular about pointer semantics). Instances (i.e., objects) don't have "names", they just exist -- and the array you get back from 'allInstances' is indeed an array of instances, not an array of classes. So, let me proceed with solutions based on a guess as to what your actual situation is. I guess that you are either: (a) modifying system supplied classes, or (b) modifying classes that you yourself have written. I guess that you are doing (a) or (b), but not both. If you are modifying system supplied classes, try circumventing the problem by making subclasses of the classes you want to change, leaving the originals intact, and using the subclasses rather than the originals. This approach will only allow you to add instance variables, not remove them, but that's life. If you are modifying classes that you yourself have written, return to a system that does not have those classes added yet (so no instances exist), file the class definitions in, then add/remove variables as you see fit. The add/removes will cause recompilations but will work. (An alternative strategy is to manually edit the file containing the filed out definitons, adding/removing the variables in the file, and then filing in. Not a bad approach -- it's easy to figure out where to put those '!'s -- but be sure to keep a backup copy of the original file!) If you don't have a file out of your classes, the easiest thing might be to just type them in again (ugh!). [If anyone out there is using Smalltalk/V, is not filing out change sets, but wants to, reply by mail. Have I got a deal for you....] If you really are doing both (a) and (b), a combination of the two strategies may work. If neither of the proposed strategies is viable for you, and you are desparate enough to try a "flag day" approach, do the following: For each class C that you want to change Create C' that is just like C but with variables added/removed Execute smalltalk/V code "C allInstances do: [ :inst | inst become: (C' basicNew copyFromC: inst) ]" (You will have to have written 'copyFromC:' to do the right thing) Remove C from the system (C should now have no instances) Rename C' to C End for If the classes to be changed are all leaf classes (no subclasses) the above should work as written. If you need also to change non-leaf classes, changing C to C' means first changing S to S' for each subclass S of C. Hope this helps. cheers, Tim
franka@mmintl.UUCP (02/17/87)
In article <3060@gitpyr.gatech.EDU> krubin@gitpyr.UUCP (Kenny Rubin) writes: >QUESTION: how does one determine the names of instances that > have been created for a given class by application > of the 'new' method selector? > >PROBLEM: when I make a modification to a given class, ..., I cannot > save the modification (from the ClassHierarchyBrowser). > Attempting to do so results in a window popping up that > says "Has Instances". The solution to the problem seems > to be to find all instances of the class (or subclass) > and set them equal to something other than an object of > the class I am trying to modify. Unfortunately, I can't > seem to be able to locate the names, and more so, who > is using them (containing the names). There is no facility in the system to identify all these references. Even if there were, this would not suffice, since many objects do not have names which can be assigned to. (Most objects are instance variables for other objects, and as such can only be assigned by methods for their class. Further, some are predefined by the system.) The general solution is to create a new value for each instance, and to use the become: message to change the instance to the new value. Care must be taken in this process; if you do not understand the Smalltalk data model, you are very likely to break something. Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108
dhelaan@orstcs.UUCP (02/25/87)
There is a class called SystemDictionary, that keeps track
of everything in the system, of which there is one instance
called Smalltalk all the time.
To remove a class or change its variables you need to remove all
its instances first. To know all the defined instances in the system
just execute the following statement.
"Smalltalk keys"
which will display a set of all the defined instances in the system.
then either remove it or redefined it.
Try also using the Inspector.