8.1 Storage--An Introduction

To this point the main concern of the text has been issues of data and program structure--how to represent data effectively, and how to implement in the Modula-2 notation an effective means of manipulating that data. Little has been said thus far about how that data is stored, either in the machine itself or on external media. As long as the amount of data is relatively small, this approach suffices, for small amounts of data can be typed in with each program run, and without much concern for how it is stored in the machine.

However, there comes a point when attention must be given to data storage issues, for at the program level the amount of data eventually becomes too large to enter anew with each run of a program. In the real world, data collections are very large, and new programs are frequently written for the sole purpose of manipulating files of existing data collections in ways not previously thought of. Such programs must be structured with the existing stored data in view. The file manipulation facilities provided by the simple classical high level Module InOut or that can be attached to STextIO using RedirStdIO are very primitive and will not do for much beyond simple demonstration purposes. Thus, a Modula-2 implementation always has a suite of more elaborate modules for handling files and arranging for I/O between those files and a running program.

Likewise, there are aspects of the internal data storage that are worthwhile knowing, even though many programmers will not make extensive use of this knowledge. Since some of this has an impact on the understanding and use of file handling modules, this chapter will begin with the internal storage issues, and later consider the external ones. Depending on the depth required by a given student, it may be possible to give this first part only a light read and move into Part B. On the other hand, extensive low level work will require much more experience and knowledge than can be obtained in this chapter. However, the information given here will provide the basis for applying that knowledge to a solution not only when using Modula-2, but also for other notations.