4. Declarations and scope rules
Every identifier occurring in a program must be introduced by a declaration,
unless it is a predeclared identifier. Declarations also specify certain
permanent properties of an object, such as whether it is a constant, a type, a
variable, or a procedure. The identifier is then used to refer to the associated
object.
The scope of an object x extends textually from the point of its
declaration to the end of the block (module, procedure, or record) to which the
declaration belongs and hence to which the object is local. It excludes
the scopes of equally named objects which are declared in nested blocks. The
scope rules are:
- No identifier may denote more than one object within a given scope (i.e. no
identifier may be declared twice in a block);
- An object may only be referenced within its scope;
- A typeT of the form POINTER TO T1 (see 6.4) can be declared at a point where
T1 is still unknown. The declaration of T1 must follow in the
same block to which T is local;
- Identifiers denoting record fields (see
6.3) or type-bound procedures (see
10.2) are valid in record designators only.
An identifier declared in a module block may be followed by an export mark (" * "
or " - ") in its declaration to indicate that it is exported. An identifier
x exported by a module M may be used in other modules, if they
import M (see Ch.11). The identifier is then
denoted as M.x in these modules and is called a qualified
identifier. Identifiers marked with " - " in their declaration are
read-only in importing modules.
| Qualident | = | [ident "."] ident.
|
| IdentDef | = | ident [" * " | " - "].
|
The following identifiers are predeclared; their meaning is defined in the
indicated sections:
Previous Section, Next Section,
Contents
Adapted to HTML by Jürgen
Geßwein; 8. Juni 1995