The Semantics, Formal Correctness and Implementation of History Variables in an Imperative Programming Language
Ryan Mallon
Department of Computer Science
University of Canterbury
Abstract
We propose that maintaining the history of objects in a program could be simplified by providing support at the language level for storing and manipulating the past versions of objects. History variables are variables in a programming language which store not only their current value, but also the values they have contained in the past. Some existing languages do provide support for history variables. However these languages typically have many limits and restrictions on use of history variables.
In this thesis we discuss a complete implementation of history variables in an imperative programming language. We discuss the semantics of history variables for scalar types, arrays, pointers, strings and user defined types. We also introduce an additional construct called an "atomic block" which allows us to temporarily suspend the logging of a history variable. Using the mathematical system of Hoare logic we formally prove the correctness of our informal semantics for atomic blocks and each of the history variable types we introduce.
Finally, we develop an experimental language and compiler with support for history variables. The language and complier allow us to investigate the practical aspects of implementing history variables and to compare the performance of history variables with their non-history counterparts.