3.3 Function Calls

[ Table of Contents ] Prev ] Chapter Overview ] Next ] [ Glossary/Index ]

Function calls are not statements. Every function call appears as one term (perhaps the only term) in an expression -- often on the right hand side of an assignment statement.

General Form

Function_Name(actual_parameter_list)

The rules regarding parameters are essentially the same as those for procedure calls, except that all parameters of a function must be of mode in.

Here are two examples, taken from Section 7.4 of [Cohen96]. These examples provide a particularly striking illustration of the understandability of code using named association.

Source Code Listing

------------------------------------------------------------------
--  The name of the function called is Cheapest_Route. 
--  The following function call uses positional association.
------------------------------------------------------------------
Itinerary := Cheapest_Route("JFK","LAX",730,2330,"UA","Y",2);
------------------------------------------------------------------
--  The following function call uses named association.
------------------------------------------------------------------
Itinerary := Cheapest_Route
                (Origin                       => "JFK",
                 Destination                  => "LAX",
                 Earliest_Possible_Departure  => 730,
                 Latest_Possible_Arrival      => 2330,
                 Airline_Preference           => "UA",
                 Fare_Class_Desired           => "Y",
                 Length_Of_Stay               => 2);
------------------------------------------------------------------

Besides appearing in expressions on the right hand side of assignment statements, function calls often appear in Boolean expressions that produce Boolean type results used to make "branching" decisions, such as those in if statements -- as illustrated in the next page.

Related Topics

2.5 Functions 3.4 if Statements

[ Back to top of pagePrev ] Next ]