![]() |
Declarations and scope rulesEvery identifier occurring in a program must be introduced by a declaration, unless it is a standard identifier (see below). Declarations also serve to specify certain permanent properties of an object, such as whether it is a constant, a type, a variable, a procedure, or a module. The identifier is then used to refer to the associated object. This is possible in those parts of a program only which are within the so called scope of the declaration. In general, the scope extends over the entire block (procedure or module declaration) to which the declaration belongs and to which the object is local. The scope rule is augmented by the following cases:
An identifier may be qualified. In this case it is prefixed by another identifier which designates the module in which the qualified identifier is defined. The prefix and the identifier are separated by a period. qualident = ident {"." Ident}. Standard identifiersStandard identifiers are considered to be predeclared, and they are valid in all parts of a program. For this reason they are called pervasive.
ABS BITSET BOOLEAN CARDINAL CAP CHR CHAR COMPLEX CMPLX DEC DISPOSE EXCL FALSE FLOAT HALT HIGH IM INC INCL INT INTERRUPTIBLE INTEGER LENGTH LFLOAT LONGCOMPLEX LONGREAL MAX MIN NEW NIL ODD ORD PROC PROTECTION RE REAL SIZE TRUE TRUNC UNINTERRUPTIBLE VAL The pervasive identifiers COMPLEX, CMPLX, IM, INT, INTERRUPTIBLE, LENGTH, LFLOAT, LONGCOMPLEX, LONGREAL, PROTECTION, RE and UNINTERRUPTIBLE were added for ISO Modula-2. Source:
|