HP Pascal/iX Reference Manual (31502-90022)

8- 1
Chapter 8 Procedures and Functions
When a procedure or function is declared, the heading may optionally
include a list of
parameters
. This list is called the
formal parameter
list
. A procedure statement or function call in the body of a block
provides the matching actual parameters that correspond by their order in
the list. The four kinds of formal parameters are
value, reference,
functional
, and
procedural
parameters.
Value parameters
are identifiers
followed by a colon (
:
) and a
type identifier
or a
conformant array
schema
.
Reference parameters
are declared like value parameters, but are
preceded by the reserved word VAR.
Functional
or
procedural parameters
are function or procedure headings.
The four types of formal parameters may be repeated and intermixed.
Several identifiers may appear separated by commas. These identifiers
then represent formal reference or value parameters of the same type,
even if the type is a
conformant array schema
.
A
formal value parameter
appears as a local variable during execution of
the procedure or function. It receives its initial value from the
matching actual parameter. Modification of the formal parameter cannot
affect the actual parameter which may be an
expression
. The actual
parameter must be assignment compatible with the formal parameter or, in
the case of a conformant array parameter, must conform with the formal
parameter.
A
formal reference parameter
represents the actual parameter during
execution of the procedure. Any changes in the value of the formal
reference parameter alters the value of the actual parameter, which must
be a variable access. The actual parameter must have a type identical
with the formal parameter or conform with the formal parameter, in the
case of a
conformant array schema
.
When a
conformant array schema
is specified, the value of the upper bound
and the value of the lower bound identifiers in the schema vary according
to the actual bounds of the array passed as the actual parameter. They
can be accessed as value parameters in the procedure, except their values
cannot be changed. Their names have the same scope as a parameter. The
type of the actual parameters must be conformable with the conformant
array schema. The formal parameters have a type that is distinct from
any other type. This means that the actual parameters are not assignable
to any other variable or parameter except those of the same type. The
type cannot be a PAC type since the lower bound cannot be fixed as one.
This makes passing string literals as actual conformant array parameters
an error in ISO Pascal. HP Pascal is extended to allow the passing of
string literals as parameters. However, a conformant array cannot be
manipulated as a string.
An actual conformant array parameter can be passed as a reference
conformant array parameter, but not as a value parameter of any kind.
A
formal procedural
or
functional parameter
is a synonym for the actual
procedure or function parameter. The parameter lists, if any, of the
actual and formal procedural or functional parameters must be congruent.
Two formal parameter lists are congruent if they contain an equal number
of parameters, and the parameters in corresponding positions are
equivalent. Two parameters are equivalent if any of the following
conditions are
true
:
* They are both value parameters of the identical type.
* They are both reference parameters of the identical type.