HP Pascal/iX Reference Manual (31502-90022)

11- 15
func_2 := nil; { initialized to nil }
proc_0 := addr( p1 ); { proc_0 now 'points to' p1 }
proc_1 := addr( p2 ); { illegal: parameters don't match }
proc_1 := addr( p3 ); { illegal: parameters don't match }
func_0 := addr( p1 ); { illegal: must be a function }
END.
Example
TYPE
proc_type = PROCEDURE;
VAR
proc_var_0 : proc_type;
PROCEDURE proc_1;
VAR
proc_var_1 : proc_type;
PROCEDURE proc_2;
BEGIN {PROCEDURE proc_2}
...
END; {PROCEDURE proc_2}
BEGIN {PROCEDURE proc_1}
proc_var_0 := addr( proc_1 );
proc_var_1 := addr( proc_1 );
proc_var_0 := addr( proc_2 ); { illegal: scoping violation }
proc_var_1 := addr( proc_2 );
END; {PROCEDURE proc_1}
Expressions
Type Coercion
Pascal is very strict with respect to type checking. In any operation
such as assignment, binary operations, passing parameter, or indexing,
relevant types must be compatible according to the HP Pascal rules of
compatible types. Refer to "Type Compatibility" for more
information.
Type coercion allows the user to selectively circumvent the normally
strong type checking. The system programming extensions support several
forms of type coercion including ANYVAR, reference, and value. ANYVAR
type coercion (using the formal parameter mechanism ANYVAR) is described
in this chapter under "Procedures and Functions" .
Reference
type coercion consists of type coercion of an actual parameter
that is being passed to a reference formal parameter, or type coercing a
pointer to a different pointer type before a dereference.
Value
type coercion consists of type coercion of a constant, variable,
function result, or expression to a different type.
The syntax for type coercion looks like the application of a function to
an expression, where the name of the function is the name of the target
type of the coercion.
Syntax
Expression:
The expression being coerced may be a constant, variable, function
result, or expression involving unary and binary operators.