SPL to HP C/XL Migration Guide (30231-90001)

6-11
means of accomplishing the same operation as the SPL example.
Stacking Parameters
By directly manipulating the hardware stack in MPE V, SPL programmers
can set up parameters to a procedure directly and then call the procedure
using "*" actual parameters.
There is no equivalent in HP C/XL. However, replacing the "*"s in the
parameter list with the stacked values is functionally equivalent.
(Usually, the procedure call is preceded by assignments to TOS, which
can be thus eliminated.)
This technique is used in SPL mostly to optimize runtime performance,
not
to gain otherwise unavailable functionality. A simple rewrite will
eliminate any explicit references to the stack.
Missing Parameters in Procedure Calls
If an SPL procedure is declared with OPTION VARIABLE, parameters may be
omitted from the actual parameter list when the procedure is called.
HP C/XL provides the varargs macros to enable variable-length actual
parameter lists. This feature is described further in "Options", and in
the
HP C/XL Library Reference Manual
.
Passing Labels as Parameters
SPL has an elaborate facility for passing labels to procedures as actual
parameters. When control is transferred to the label, the procedure
automatically performs an exit from itself (and from any other proce-
dures in the calling sequence between this one and the one containing the
passed label) prior to transferring control to the label location. This
effectively "unwinds" a stack of procedure calls, and is most often used
in error recovery.
HP C/XL does not permit labels to be passed as parameters. These
situations can (and must) be rewritten, possibly by declaring a global
flag variable to indicate error conditions. This flag should be tested
by functions to determine if processing is to be terminated prematurely.
Another approach is to use the longjmp and setjmp functions described in
the
HP C/XL Library Reference Manual
.
Passing Procedures as Parameters
An SPL procedure (e.g., A) may be passed to another procedure (e.g., B)
as a pass-by-reference parameter. When A is called from B, the actual
parameters supplied in the parameter list at the time of the call are
assumed to be pass-by-reference. Pass-by-value actual parameters
must
be placed on the stack and specified with the "*" symbol in the procedure