SPL to HP C/XL Migration Guide (30231-90001)
8-: 3
| "Options" below. | |
|||
---------------------------------------------------------------------------------------------
|||
|
procedure-body
:|
function-body
:|
|||
|a.
statement
|a.
"
{
" statement "
}
"
|
|||
| b. BEGIN | b.
"
{
"
|
|||
|[
local-data-declarations
]|[
local-declarations
]|
|||
|[
external/intrinsic-declarations
]| [
statement
[...] ] |
|||
|[
local-subroutine-declarations
]|
"
}
"
|
|||
|[
statement
[;...] ] | |
|||
| END | |
|||
---------------------------------------------------------------------------------------------
|||
| A procedure declaration: | A function definition: |
|||
| * defines a procedure identifier | * defines a function identifier |
| * specifies whether the procedure will | * specifies whether the function will NOT |
| return a value (
type
) | return a value (void) |
| * describes the parameters: number, | * describes the parameters: number, type |
| type, pass-by-value or | (all are pass-by-value) |
| pass-by-reference | * specifies a storage class |
| * specifies any options | * declares local variables |
| * declares local variables | * includes the statements of the function |
| * includes the statements of the | body |
| procedure body | |
|||
---------------------------------------------------------------------------------------------
|||
| Procedure declarations cannot be nested, | Same as SPL, using the extern storage |
| except that a procedure with OPTION | class. |
| EXTERNAL and no body may be declared in a | |
| procedure's local declarations. | |
|||
---------------------------------------------------------------------------------------------
Data Type
Table 8-3. Data Type
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
| Default type: None | Default type: int (= long int) |
| | |
---------------------------------------------------------------------------------------------
| | |
| If
type
is specified, the procedure is a | Functions normally return a value and may |
| function procedure, which may be called in | be called in expressions. The value |
| an expression. The value returned is the | returned may be any type except array or |
| type specified. | another function. |
| | |
---------------------------------------------------------------------------------------------
| | |
| If
type
is omitted, the procedure does not | If the void type is specified, the function |
| return a value and cannot be used in | does not return a value and cannot be used |
| expressions. | in expressions. |
| | |
---------------------------------------------------------------------------------------------
| | |
| A value is returned by assigning it to the | A value is returned in a return statement: |
|
procedure-id
in the body of the procedure: | |
| | |