In classic Pascal which is most used by software testing companies in Bangalore, all variables are created in an undefined state (that is, containing an undefined value). In Extended Pascal, an initial state can be defined which is automatically given to a variable when it is created. At the outer level, an implementation may preset the initial state, but the facility also applies to local variables of procedures and variables created on the heap. Furthermore, a type definition may carry an initial state, which is given to every variable of the type unless the variable declaration itself overrides it.
Modules of Pascal
Classic Pascal does not include any facility for separate compilation of parts of a program. Besides limiting the scope of programs which can be produced on small machines, this has the important disadvantage that there is no standard form for the preparation of precompiled libraries. Almost every implementation of Pascal introduced an extension of some kind to overcome this limitation, and it was seen as one of the most important tasks of Extended Pascal to define a form of separate compilation which would not forfeit type security.
Besides the main program, Extended Pascal programs may include components known as modules. A module can export constants, types, variables, procedures and functions through named interfaces, and these interfaces may be imported by other modules or by the main program. By default, an interface is imported complete, with the names of all its constituents accessible, but there are several options to meet the difficulties which can arise in practice when importing from modules which were not designed in conjunction with one another. Instead of importing the whole of an interface, just selected items may be chosen; the names of constituents may be kept apart and referred to by giving the interface name, and constituents may be renamed on import.
A module has two parts: a heading and a block. The module heading contains declarations and definitions of any items which are to be exported, in particular the headings (but no more) of procedures and functions. The block includes the definitions of any exported procedures or functions, together with items which do not need to be known outside the module. There may also be initialization and finalization code.
The heading and block may be combined or separate. When separate, the possibility arises of alternative implementations of the same heading (with and without diagnostic code, for example), or of an implementation coded in some other languages such as assembler.
A module heading may import from another module and may re-export these imported items, allowing, for example, composite library interfaces to be constructed. A module block may independently import interfaces from other modules. The export and import of an interface set up what is known as a “supplying” relationship, in which the exporting module supplies the importing module or program. The supply network puts some constraints on the sequence in which modules can be compiled; in particular, it must not contain any loops (which would imply that a module was indirectly attempting to supply itself). Any initialization code for a module is executed before that of any component which it supplies.