Previous: 2.2.12. Procedures and Functions To the Table of Contents Next: 2.2.12.2. Forward Declaration
2.2.12. Procedures and Functions Table of Contents 2.2.12.2. Forward Declaration

- 2.2.12.1. -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.12. Procedures and Functions
2.2.12.1. Declaration


2.2.12.1. Declaration


Procedures and functions take the following form:
procedure identifier [(Parameterlist)]}
or
function identifier [(Parameterlist)] : ReturnType}
ReturnType is the type of the value returned by the function. Parameterlist is defined as:
  Parameter [;Parameter]}
where Parameter is:
  [var] identifier [,identifier] [: TypeName]}
or
  [const] identifier [,identifier] [: TypeName]}
var specifies a variable parameter. const specifies a constant parameters. var and const parameters are passed by reference as opposed to being passed var and const parameters are passed by reference as opposed to being passed by value.

The body of a procedure or function takes the following form:
[Declarations]
begin
  statement [; statement]
end;
Types, labels, constants, and variables declared in the declaration section prior to the begin statement are local variables. Space for these variables is allocated only when the procedure is called. Like all variable declarations their data is undefined until initialized. TMT Pascal procedures and functions may be called recursively.

All identifiers must be declared prior to being referenced. The same rule applies to procedures and functions.


Previous: 2.2.12. Procedures and Functions To the Table of Contents Next: 2.2.12.2. Forward Declaration
2.2.12. Procedures and Functions Table of Contents 2.2.12.2. Forward Declaration

- 2.2.12.1. -