HP Pascal/iX Programmer's Guide (31502-90023)
7- 1
Chapter 7 Parameters
This chapter explains:
* The differences between value and reference parameters.
* ANYVAR and READONLY reference parameters (which are HP Pascal
system programming extensions).
* Conformant array parameters.
* Routines (procedures and functions) as parameters.
* Congruent parameter lists.
* Hidden parameters (which affect debugging and interfacing with
external non-Pascal routines).
NOTE This chapter is intended for system software developers who already
understand the systems for which they are programming. Its purpose
is to explain the HP Pascal features of which they must be aware.
It does not attempt to teach systems programming.
Value versus Reference Parameters
The terms
value
and
reference
must be explained in terms of formal and
actual parameters. A
formal parameter
is defined in a routine header.
An
actual parameter
is passed in a call to a routine.
Example 1
PROGRAM prog;
VAR
a : integer;
PROCEDURE p (f : integer); {f is a formal parameter}
BEGIN
END;
BEGIN
p(a); {a is an actual parameter}
END;
A
value parameter
is passed by value; that is, the value of the actual
parameter is passed to the routine and assigned to the formal parameter.
If the routine changes the value of the formal parameter, it does not
change the value of the actual parameter. An actual value parameter can
be a constant, an expression, a variable, or a function result.
A
reference parameter
is passed by reference; that is, the address of the
actual parameter is passed to the routine and associated with the formal
parameter. If the routine changes the value of the formal parameter, it
changes the value of the actual parameter. An actual reference parameter
must be a
variable access
(a variable name or the name of a component of
an unpacked structure).
HP Pascal without system programming extensions has one kind of reference
parameter: VAR. For more information on VAR parameters, refer to the
HP
Pascal/iX Reference Manual
or the
HP Pascal/HP-UX Reference Manual
,