Previous: 2.2.6.18. Type Compatibility To the Table of Contents Next: 2.2.7.1. Type Declarations
2.2.6.18. Type Compatibility Table of Contents 2.2.7.1. Type Declarations

- 2.2.7. -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.7. Declarations


2.2.7. Declarations


The name of each identifier must be declared in your source code. By declaring an identifier to be of a particular type, such as a variable, or constant, you define its size and attributes.

Pascal is a block structured language. Each program, unit, procedure and function defines a block. Blocks can be nested creating blocks within blocks. The block structure effects the interpretation of identifiers such as constants, variables, types, and so on. Identifiers can havedifferent meanings depending upon which block is referenced.

When an identifier is declared it is defined from the point of its declaration to the end of the inner most block that contains the declaration. This is the scope of the identifier. Redefinitionof an identifier is not allowed within the same block in which it was declared. Only in nested blocks may an identifier be redefined. However the new identifier does not refer to the old identifier. In fact the old identifier is hidden until the end of the nested block.

In addition to the traditional Pascal syntax, TMT Pascal also allows local block declarations. These are described below in the manual.

An identifier may not be referenced prior to its declaration with one exception. A type name can be used as the base type of a pointer if the name is then declared in the type declaration that contains the reference. For instance:
type
  CoordPtr   = ^Coordinate;
  Coordinate = record;
    x, y     : Integer;
  end;
As you can see Coordinate is referenced prior to its declaration. The above declaration is valid due to the fact that Coordinate is declared in the same type declaration as CoordPtr.

There are several declarations possible under TMT Pascal. They include:


Previous: 2.2.6.18. Type Compatibility To the Table of Contents Next: 2.2.7.1. Type Declarations
2.2.6.18. Type Compatibility Table of Contents 2.2.7.1. Type Declarations

- 2.2.7. -