READONLY Parameters [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
READONLY Parameters
A READONLY parameter is similar to a value parameter in that the routine
cannot directly modify its actual parameter, which can be a constant, an
expression, or a variable. READONLY differs from a value parameter in
that the routine cannot modify the formal parameter: you cannot assign a
value to the formal READONLY parameter, pass it to a VAR or ANYVAR
parameter, or pass it to either of the predefined functions addr,
baddress, or waddress.
A READONLY parameter is similar to a VAR or ANYVAR parameter in that its
actual parameter is passed by reference. If the actual parameter is an
expression or constant, a copy of its value is passed by reference.
Example
PROGRAM prog;
$STANDARD_LEVEL 'HP_MODCAL'$
TYPE
arraytype = ARRAY [1..10] OF integer;
CONST
arrayconst = arraytype [10 OF 0];
VAR
arrayvar : arraytype;
FUNCTION arrayfunc : arraytype; EXTERNAL;
PROCEDURE p ( valuep : arraytype;
VAR varp : arraytype;
READONLY readonlyp : arraytype); EXTERNAL;
BEGIN
p(arrayconst, {value is passed}
arrayconst, {illegal -- must be a variable}
arrayconst); {address of copy of value is passed}
p(arrayvar, {value is passed}
arrayvar, {address is passed}
arrayvar); {address is passed}
p(arrayfunc, {value is passed}
arrayfunc, {illegal -- must be a variable}
arrayfunc); {address of copy of value is passed}
END.
The comments in the preceding program explain the differences in passing
a constant (arrayconst), a variable (arrayvar), and an expression (a call
to the function arrayfunc) to a value parameter (valuep), a VAR parameter
(varp), and a READONLY parameter (readonlyp).
MPE/iX 5.0 Documentation