ABSTRACT

So far we have considered only three different kinds of program units, namely the main program, subroutines, and functions. Program execution always starts with a main program, from which subroutines and functions (collectively called “procedures”) may be called. Procedures may call on other procedures in turn. Whenever a procedure is called, a list of arguments is used to pass data in either direction between the two program units, the calling and the called. In the case of functions, of course, the function name itself transfers data back from the function. If a procedure is written to carry out a simple self-contained operation, like calculating a simple mathematical function, then data transmission by argument passing may be good enough, but in general it can be very useful, if not essential, to have a way in which program units can share larger sets of data in a more flexible and open way. Modules provide a method of doing this.