Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!rayssd!trr From: trr@rayssd.ray.com (Terry R. Raymond) Newsgroups: comp.lang.smalltalk Subject: Re: Smalltalk/V: adding new instance variable Message-ID: <8353@rayssd.ray.com> Date: 22 Jun 89 16:51:27 GMT References: <17@piyopiyo.hatori.t.u-tokyo.JUNET> Sender: trr@rayssd.ray.com (Terry R. Raymond @ Raytheon Company, Portsmouth RI) Organization: Raytheon Company, Portsmouth RI Lines: 24 If you look at the description of user-defined primitives in the Accessing Object within primitives section of the manual, you will see that it states that the instance variables in the object are in the same order in which they are defined by the class definition. The primitives access the variables by knowing the "offset". If you add a new variable it could easily cause an error with a primitive that uses an instance variable. Compiled smalltalk code is "probably" very similar. I assume that when a method references an instance variable the compiler compiles the reference as an offset. Therefore, when a method, that has been recompiled against a class definition that has a new instance variable, references an old instance, one without the new variable, the reference may be wrong. The moral is it can be difficult to add a new instance variable to a class that has instances, or to a class that has a primitive that references instance variables. -- Terry Raymond Raytheon Submarine Signal Division; Portsmouth RI; (401)-847-8000 x5597 ------------------------------------------------------------------------------ Internet: trr@rayssd.ray.com (trr%rayssd.ray.com@a.cs.uiuc.edu) UUCP: {decuac,gatech,mimsy,mirror,necntc,sun,uiucdcs,ukma}!rayssd!trr