[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.1.6.4 Subroutine Parameter List Declaration

 
parameter; ...; parameter

Value parameters are declared this way:
 
parameter identifier: parameter type
where parameters of the same type be listed, separated by commata:
 
parameter identifier, ..., parameter identifier: parameter type

If var is specified before a parameter, which is an USCD extension, the compiler is told to pass the argument by reference, i.e. the parameter passed to is expected to be an L-value whose type is parameter type if specified, else it is compatible with any type:
 
var parameter identifier: parameter type
or without type specification:
 
var parameter identifier
This declaration is necessary if the parameter is to be modified within a block and to hold its value still after return. Otherwise, the parameter remains unchanged after block exit, since it is passed by value, and therefore it is called value parameter.

A parameter of this kind is called variable parameter and corresponds to an L-value pointer (to type identifier if specified). As a Borland Pascal extension, there are also constant parameters which are not allowed to be changed in the related statement part. Like variable parameters, the type needs not to be declared; in this case parameter identifier is treated as a typeless parameter.
 
const parameter identifier: parameter type
or without any further type specification:
 
const parameter identifier

As an Extended Pascal extension, there is a way to declare procedural parameters directly:
 
procedure parameter identifier
or without type specification:
 
function parameter identifier: parameter identifier result type

Example for parameter lists:
 
procedure Foo (var Bar; var Baz: Integer; const Fred: Integer);

procedure Glork1 (function Foo: Integer; procedure Bar (Baz: Integer)); begin Bar (Foo) end;

begin baz := Integer (Bar) + Fred end;

See also

section 8.2 Data Types


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html