Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!bellcore!texbell!uhnix1!sugar!ficc!cliff From: cliff@ficc.uu.net (cliff click) Newsgroups: comp.lang.smalltalk Subject: Re: Smalltalk/V: adding new instance variable Summary: "Has instance" Message-ID: <4630@ficc.uu.net> Date: 20 Jun 89 13:15:07 GMT References: <17@piyopiyo.hatori.t.u-tokyo.JUNET> Organization: Ferranti International Controls Lines: 25 In article <17@piyopiyo.hatori.t.u-tokyo.JUNET>, ott@piyopiyo.hatori.t.u-tokyo.JUNET (ott) writes: > Using Smalltalk/V. Why is it not possible to add a new instance > variable to a class when it has already some? > > I get the error message 'Has instance' ... If you have any instances of that class floating around and your trying to add or delete fields from the instance Smalltalk would have to find each occurance of objects of this class and "edit" them somehow to reflect the new declaration for the class. IMHO it should do this, keeping any original data that it can, tossing deleted fields and adding the new fields with nils - this won't be a fast operation, but it would be a darn sight more convenient than "Has instance". There is a way to get Smalltalk to put all of the objects which have a pointer to these instances in a dictionary. You can then search each object in the dictionary looking for instances of your class in them, and replacing those instances with nil. When you are done you will have destroyed all references to the class's objects, so those objects will go away, and you will no longer "have instances". -- Cliff Click, Software Contractor at Large Business: uunet.uu.net!ficc!cliff, cliff@ficc.uu.net, +1 713 274 5368 (w). Disclaimer: lost in the vortices of nilspace... +1 713 568 3460 (h).