The following tables highlight similarities and differences between subroutines and functions:
Similarities between Subroutines and Functions |
Can be internal or external.
Uses the RETURN instruction to return to the caller. |
Differences between Subroutines and Functions |
Subroutines | Functions | |
Calling | Call by using the CALL instruction, followed by the subroutine name and, optionally, up to 20 arguments. | Call by specifying the function's name, immediately followed by parentheses that optionally contain up to 20 arguments. |
Returning a Value | Might return a value to the caller. If you include a value on the RETURN instruction, the language processor assigns this value to the REXX special variable RESULT. | Must return a value. Specify a value on the RETURN instruction; the language processor replaces the function call with this value. |