Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 UW 5/3/83; site uw-june
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!houxm!hogpc!houti!ariel!vax135!cornell!uw-beaver!uw-june!trow
From: trow@uw-june.UUCP
Newsgroups: net.lang.st80
Subject: Re: instance variable question
Message-ID: <1838@uw-june>
Date: Fri, 5-Oct-84 22:13:15 EDT
Article-I.D.: uw-june.1838
Posted: Fri Oct  5 22:13:15 1984
Date-Received: Mon, 8-Oct-84 02:43:22 EDT
References: <15992@arizona.UUCP>
Reply-To: McCall@Xerox.arpa
Organization: U of Washington Computer Science
Lines: 51


Forwarded from Smalltalk80Interest^@Xerox

----------------------------------------------------------------

Date: Fri, 5 Oct 84 16:08:35 PDT
From: McCall.pa
Subject: Re: instance variable question
To: arizona!budd@ucbvax (tim budd)
cc: Smalltalk80Interest^

You say: consider the situation in which we remove an instance variable
from a class, and some method in one of its subclasses refers to that
instance variable.  

You ask: What happens when we create an instance of the sublcass?

I ask: Why confuse the issue by talking about subclasses?  The problem
is essentially the same if we remove an instance variable from a class
which has methods refering to that variable (or to any other "higher
numbered" instance variables, for that matter).

There are two interrelated issues:
	(1) What happens to references to the old variable?
	(2) What do new instances of the newly created class look like?

The solution adopted in Smalltalk-80 (Xerox Smalltalk) is to "recompile"
the class.

The first time the old variable name is encountered, it is entered in a
special dictionary (which is listed in the global dictionary under the
name Undeclared).  This dictionary is similar in structure to the global
dictionary.  So the old instance variable has become, in essence, a
global variable (with the obvious problems if two different instances
want different values for that variable, which the writer of the code
thought was local to the instances.)  The only notification to the user
that such a change is taking place is the inclusion of 'xxx is
Undeclared' in the garbage being printed in the System Transcript (where
'xxx' is the name of the old instance variable.)

This "solution" extends smoothly (if slowly) to include your case in
which the variable is refered to by methods in subclasses.  Simply
recompile the methods in the subclasses as well.

Since references to the lost variable now refer to a global and all
other instance variable offsets have been revised by the recompilation,
new instances of the class (or of its subclasses, as you wondered) can
be shorter (omitting the deleted variable.)

----------------------------------------------------------------