Computing in Science and Engineering, 14 (1) 80-86
publié le , mis à jour le
The notion of state is fundamental to the study of dynamical systems. State refers to the minimal set of information that fully describes the system at a specific time. The simplest state model is found in Fortran 77, where a program’s state consists of the values of all its scalar variables and of all the elements of all arrays, the statement to be executed next, and the statements at which execution resumes at the end of each active subroutine or function. In the following, I’ll concentrate on the variables, because the statement references are part of control flow and not directly accessible to the programmer. It’s important, however, to remember that each state is associated with a precise point in the program’s execution. The two important concepts in understanding data handling in Fortran 77 are thus value and variable, where the latter term includes the elements of arrays. Each variable has a value at each point in execution. This value is changed by an assignment statement. It can be used in an expression, where it’s combined with other values (constants or the values of other variables) by operations, such as arithmetic, to produce new values. Languages such as C or Fortran 90 that offer pointers and dynamic memory allocation lead to a much more complicated description of state. Obviously the contents of the dynamically allocated storage must be included in the total state of a program, but that’s only the first step. Each such storage block can itself contain pointers to other storage blocks. The neat distinction between variables and values disappears : the value of a variable can define another variable. As a consequence, it’s no longer possible to compile a list of all parts of a program’s state just by looking at its source code. What is or isn’t part of the state is defined by the state itself.