SPL to HP C/XL Migration Guide (30231-90001)
8- 4
| | return
expression
; |
|
procedure-id
:=
expression
| |
| | For easier conversion, declare a local |
| For example: | variable, e.g., returnvalue, and replace |
| | the
procedure-id
with it in the function |
| INTEGER PROCEDURE FUNC ; | body. Then replace all the SPL RETURN |
| BEGIN | statements with "return returnvalue" Add |
| ... | one before the final "}": |
| FUNC := Y + Z ; | |
| ... | short int FUNC () ; |
| RETURN ; | { |
| ... | short int returnvalue ; |
| FUNC := A - B ; | ... |
| ... | returnvalue := Y + Z ; |
| END ; | ... |
| | return returnvalue ; |
| | ... |
| | returnvalue := A - B ; |
| | ... |
| | return returnvalue ; |
| | } |
| | |
---------------------------------------------------------------------------------------------
Parameters
Table 8-4. Parameters
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Formal parameters are defined by type (in | Formal parameters are defined by type (in |
| the
formal-parm-decl
section) and by | the
formal-parm-decl
section). All are |
| whether they are pass-by-reference (the | pass-by-value. |
| default) or pass-by-value (named in the | |
| VALUE section). | |
| | |
---------------------------------------------------------------------------------------------
| | |
| Simple variable and pointer formal | Simple variable formal parameters expect a |
| parameters may be pass-by-value or | value. Array, function, and pointer formal |
| pass-by-reference. Array, procedure, and | parameters expect a pointer value. |
| label formal parameters are | Consequently, the operation for arrays and |
| pass-by-reference only. | functions is functionally equivalent to SPL |
| | pass-by-reference. The operation for |
| "Reference" formal parameters expect the | simple variables and pointers is |
| address of the actual parameter. "Value" | functionally equivalent to SPL |
| formal parameters expect the value of the | pass-by-value. |
| actual parameter. | |
| | (Labels cannot be passed.) |
| | |
---------------------------------------------------------------------------------------------
| | |
| At the procedure call, if the formal | At the function call, the actual parameters |
| parameter is pass-by-value, the value of | are evaluated and converted to standard |
| the actual parameter is passed. | types. (See also "HP C/XL Rules for |
| | Automatic Numeric Type Conversion".) |
| If the formal parameter is | |
| pass-by-reference and the actual parameter | * [unsigned] char and short int become |
| is an appropriate identifier, array | [unsigned] int (= [unsigned] long int) |
| reference or pointer reference, the address | * float becomes double |
| of the actual parameter is passed; if the | * array identifiers become "pointers to |
| actual parameter is a constant or | array of type T" |
| expression, then its value is passed as the | * function identifiers become "pointers |
| address. | to function returning type T" |
| | * pointers are unchanged |
| It is possible to pass addresses in SPL as | * structures are unchanged (they are |
| type LOGICAL or INTEGER parameters. Such | copied into the function space) |
| operations must be examined carefully to | |
| determine the function performed in the | The conversions are based on the actual |
| original SPL code. | parameters, not on the corresponding formal |