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:

  1. No identifier may denote more than one object within a given scope (i.e. no identifier may be declared twice in a block);
  2. An object may only be referenced within its scope;
  3. 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;
  4. 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:
ABS      (10.3)    LEN       (10.3)
ASH (10.3) LONG (10.3)
BOOLEAN (6.1) LONGINT (6.1)
CAP (10.3) LONGREAL (6.1)
CHAR (6.1) MAX (10.3)
CHR (10.3) MIN (10.3)
COPY (10.3) NEW (10.3)
DEC (10.3) ODD (10.3)
ENTIER (10.3) ORD (10.3)
EXCL (10.3) REAL (6.1)
FALSE (6.1) SET (6.1)
HALT (10.3) SHORT (10.3)
INC (10.3) SHORTINT (6.1)
INCL (10.3) SIZE (10.3)
INTEGER (6.1) TRUE (6.1)

Previous Section, Next Section, Contents
Adapted to HTML by Jürgen Geßwein; 12. Juni 1995