Subroutine Definitions and Calls
A subroutine definition contains
You cannot nest subroutine definitions; that is, you cannot define a subroutine within a subroutine definition.
- a template for calls to the subroutine
- optional variable declarations
- statements; among these can be a Return statement that when executed returns a value and exits the subroutine
The way you call a subroutine is determined by the way the subroutine
was defined:
The sections that follow describe how to define and call subroutines.
- You must provide all the parameters specified in the definition.
- You must provide either labeled parameters or positional parameters, as specified in the definition.
Subtopics
- Subroutines With Labeled Parameters
- Subroutines With Positional Parameters
- The Return Statement