HP Pascal/iX Programmer's Guide (31502-90023)

7- 2
depending on your implementation.
HP Pascal with system programming extensions has two additional kinds of
reference parameters: ANYVAR and READONLY. An actual READONLY parameter
can be a constant, an expression, or a function result.
Example 2
PROGRAM prog;
VAR
a,b : integer;
PROCEDURE p ( x : integer; {x is a value parameter}
VAR y : integer); {y is a reference parameter}
BEGIN
x := x+1; {this does not change x's actual parameter}
y := y+1; {this does change y's actual parameter}
writeln(x); {this writes 41}
writeln(y); {this writes 61}
END;
BEGIN
a := 40;
b := 60;
p(a,b);
writeln(a); {this writes 40}
writeln(b); {this writes 61}
END.
Table 7-1 compares the four kinds of formal parameters.
Table 7-1. Comparison of Kinds of Formal Parameters
------------------------------------------------------------------------------------------------
|| | || |
|| | || |
|| | || |
| Kind of ||Actual | Actual | Routine Can Modify |
| Formal | STANDARD_LEVEL | Parameter Can | Parameter Is ||
| Parameters ||Be | Passed By ||
|| | || |
------------------------------------------------------------------------------------------------
|| | ||||
|| | ||Parameter | Actual |
|| | |||Parameter |
|| | ||||
| Value | ANSI | Constant, | Value | Yes | No |
| | | expression | | | |
| | | variable, or ||||
| | | function | | | |
| | | result | | | |
|| | ||||
------------------------------------------------------------------------------------------------
|| | ||||
| Var | ANSI | Variable only | Reference | Yes | Yes |
|| | ||||
------------------------------------------------------------------------------------------------
|| | ||||
| ANYVAR | HP_MODCAL | Variable only | Reference | Yes | Yes |
|| | ||||
------------------------------------------------------------------------------------------------
|| | ||||
| READONLY | HP_MODCAL | Constant, | Reference | No | No |
| | | expression, ||||
| | | variable, or ||||
| | | function | | | |
| | | result | | | |
|| | ||||
------------------------------------------------------------------------------------------------