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

8- 3
can specify or omit actual parameters for them. If the second actual
parameter is specified, the first must also be specified.
The first two parameters of the procedure q are nonextension parameters;
the last two are extension parameters. A call to q must specify actual
parameters for the first two parameters, but it can specify or omit
actual parameters for the last two parameters. If the fourth actual
parameter is specified, the third must also be specified.
The number of extension parameters in an extensible parameter list is
flexible: you can add new ones later, and you need not recompile
programs that call the routine. The updated version of the routine can
use the predefined function
haveextension
to determine whether it was
passed values for specific extension parameters.
Without the DEFAULT_PARMS procedure option, the predefined function
haveextension
returns
true
and
false
under these conditions:
-------------------------------------------------------------------------------------
| | | |
| Function | Returns true | Returns false |
| | | |
-------------------------------------------------------------------------------------
| | | |
|
haveextension(x)
where
x
| If the routine was passed | If the routine was not |
| is a formal parameter of | an actual parameter for | passed an actual |
| the routine that called |
x
. | parameter for
x
. |
|
haveextension
. | | |
| | | |
-------------------------------------------------------------------------------------
NOTE A parameter cannot be referenced when
haveextension
would return
false.
Example
The procedure p has two nonextension parameters:
PROCEDURE p (n1,n2 : integer)
OPTION EXTENSIBLE 2;
BEGIN {p}
.
.
END; {p}
The program oldprog calls the procedure p:
PROGRAM oldprog;
PROCEDURE p (n1,n2 : integer)
OPTION EXTENSIBLE 2;
EXTERNAL;
BEGIN
p(1,2);
END.
The procedure p is updated and two new parameters are added. It uses the
predefined function
haveextension
to determine whether its two new
extension parameters were passed to it.
PROCEDURE p (n1,n2,e1,e2 : integer)
OPTION EXTENSIBLE 2;
BEGIN {p}
IF haveextension(e1) AND haveextension(e2) THEN BEGIN