HP Pascal/iX Reference Manual (31502-90022)

11- 39
parm3 : type3;
VAR parm4 : type4 )
OPTION EXTENSIBLE 2
DEFAULT_PARMS ( parm3 := 0,
parm4 := nil );
BEGIN
...
IF (haveextension( parm3 )) THEN
...
IF (haveextension( parm4 )) THEN
...
...
END;
In the above example, haveextension( parm4 ) returns true only if the
fourth parameter was actually supplied by the user. If it was not
supplied, then the default value is ignored, and the parameter is
not
passed.
Haveextension( parm3 ) is true if either of the following conditions are
true:
* The third or fourth parameters are supplied by the user.
* The fourth parameter is supplied and the third is defaulted.
Because the fourth parameter is EXTENSIBLE, and, therefore, by
definition all parameters to its left must be passed, the default
value for the third parameter is passed even though it was not
supplied by the user.
Haveoptvarparm.
The predefined Boolean function haveoptvarparm determines if a default
reference parameter is accessible.
Usage
haveoptvarparm
(parameter_name)
Parameters
parameter_name
The name of a default formal parameter of this or a
containing scope.
In a routine with default reference parameters, it may be necessary to
check a formal parameter to ensure that its actual parameter was supplied
by the user. The predefined function haveoptvarparm indicates for a
formal reference parameter name whether the corresponding actual
parameter was supplied by the user.
The argument to haveoptvarparm must be the name of a formal parameter
that:
* Is a VAR, ANYVAR, or PROCEDURE/FUNCTION parameter.
* Specifies a default value of NIL. See the routine OPTION
DEFAULT_PARMS.
Example
PROCEDURE proc_with_opt_parms( VAR parm1 : type1;
VAR parm2 : type2;
VAR parm3 : type3 )
OPTION DEFAULT_PARMS( parm2 := nil,
parm3 := nil );
BEGIN