| Subprogram Functions |
|
An object used for performing actions and returning values. Functions have a parameter list and an optional return value declaration, which together define the function's signature. There are two kinds of functions: methods and generic functions. A method has a body of code that is executed to compute the method's values when the method is called. A generic function consists of a set of methods, and computes its values by selecting and calling an appropriate method based on the types of the arguments. A subprogram is either a procedure or a function. A procedure specifies a sequence of actions and is invoked by a procedure call statement. Functions specify a sequence of actions and also returns a value called the result, and so a function call is an expression. A subprogram is written as a subprogram declaration, which specifies its name, formal parameters, and (for a function) its result; and a subprogram body which specifies the sequence of actions. The subprogram call specifies the actual parameters that are to be associated with the formal parameters. A subprogram is one of the kinds of program unit. |