| OCR Text |
Show an integer variable to a floating point variable. Although in general modifications should not change the type of existing variables, there is a technique that enables downward and upward compatible modifications. Downward compatibility means that old parts of the program will work on the new type. Upward compatibility means that new parts of the program will work on the old type. The technique that allows downward and upward compatibility works as follows. Each variable in the program is defined as a structure. Two special fields are added to each structure, a tag and a size. The tag denotes the type version and the size contains the size of the structure. At the beginning, the tag is zero. The type of existing fields is never changed. The type of the structure is modified by adding new fields. If there is a need to modify the structure, its tag is incremented by one, new fields are added, and the size of the structure in updated. This new representation is used only for instances of the structure that are allocated after the modification. Old instances remain the same. New parts of the program are written with knowledge about old types and their constraints. Therefore, they can maintain downward compatibility. By checking the tag, new parts can determine the status of the structure and act correspondingly. This method has an additional advantage besides compatibility. To change a type, data are not copied. This is important for the evolution of large, persistent structures, that are shared by many independent processes. If the type of a function is changed by modifying its parameters, downward and upward compatibility can be achieved using a similar method as in changing data. Two additional parameters are added to the function. The first parameter in the function serves as a tag denoting version. The second parameter denotes the number of parameters. Old parameters are never removed and their definition is never changed. New parameters are always added at the end. This method works if parameters are passed on the stack in the C style: leftmost parameters on the 95 |