Language Guide
CHAPTER 8
Handlers
Subroutine Definitions and Calls 237
SYNTAX
subroutineName ( [ parameterValue [, parameterValue ]...] )
where
subroutineName (an identifier) is the name of the subroutine.
parameterValue is the value of a parameter, which can be any valid expression.
If there are two or more parameters, they must be listed in the same order in
which they were specified in the subroutine definition.
The parentheses that enclose the series of positional parameters are a required
part of the language. They are shown in bold to distinguish them from
parentheses that show grouping but are not part of the language. The
parentheses must be included even if the subroutine definition doesn’t include
any parameters.
NOTES
A subroutine call must include all the parameters specified in the subroutine
definition. There is no way to specify optional parameters.
You can use a subroutine call as a parameter of another subroutine call. Here’s
an example.
minimumValue(2, maximumValue(x, y))
The second parameter of the call to minimumValue is the value from the
subroutine call to maximumValue. (The minimumValue subroutine is defined
in the next section.)
A call to a subroutine with positional parameters can include parameters that
aren’t literals as long as they evaluate to a pattern defined for the subroutine.
Similarly, the properties of a record passed to a subroutine don’t have to be
given in the same order they are given in the subroutine’s declaration, as long
as all the properties required to fit the defined pattern are present. The
examples that follow include subroutines with positional parameters that
define a pattern.