[Next] [Up] [Previous]

The COMMON Statement

When several variables are to be continuously shared between programs (as opposed to being passed as arguments), it is useful to avoid bothering the program loader with a large number of symbol references to resolve. For this reason, the COMMON statement is provided in FALCON. (Or, rather, the COMMON statement was provided in FORTRAN for that reason, and because it was a good idea there, FALCON has one too.)

A COMMON statement has the form

       COMMON /name/variable,variable,variable...

and places the variables referred to in consecutive non-overlapping storage locations in a large block in memory with the given name. If /name/ is omitted, a null name is assumed.

If, through EQUIVALENCE statements, any variable is linked to other variables preceding it within storage so that storage before the beginning of the first variable is referenced, an error message is produced.

In FALCON, unlike FORTRAN, EQUIVALENCE (and INTERLEAVE) statements should appear before, not after, COMMON statements referencing the same variables.

Also, unlike FORTRAN, if a variable is linked to other variables extending it in either direction through EQUIVALENCE, this does not increase the space reserved for it in COMMON: instead, an implicit EQUIVALENCE can and will be created by the COMMON statement. In the case of a variable referred to in an INTERLEAVE statement, however, space is always reserved for the whole structure, and no implicit equivalencies are created.

The COMMON block thus created is, in effect, an independent externally-compiled subprogram containing only data and no code. Each program referring to a COMMON block helps to build the block that will actually exist when the program runs, by determining its length. Only the name of the block is an external system; the variables in the block are, in each program, placed at displacements from the start of the block determined within that program itself.

Restrictions on placing initialized variables in a COMMON block will depend on the nature of the linkage loader available on the system where FALCON is implemented.

[Next] [Up] [Previous]