Previous topic | Next topic | Ada Home Page | Index
Procedures with Parameters

Procedures with Parameters

So far, since we have not talked about parameters, we have only seen procedures used as separate program units:

This has several limitations:

Parameters

A parameter = argument to a procedure

The procedure declaration shows the number and type of arguments

The procedure call supplies specific arguments

Parameter modes indicate how data may be communicated between the calling and called procedure.

Parameter association mechanisms define which actual parameters in the caller are associated with which formal parameters in the called procedure.


Parameters with bottom-up programming

procedure = operation, parameter = operand

    PUT (23);
    PUT (N, WIDTH=>2);
    PUT ("Simon says, wake up!");
    F(x)
    GET (height);
    get_integer (num, 1, 10);
    get_integer (mark, 0, 100);

parameters allow manipulation of different data

Parameters with top-down decomposition

procedure = sub-task, parameter = data/result

    begin
        get_data (data);
        compute_answer (data, answer);
        display(answer);
    end;

parameters allow communication between procedures


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 15 Feb 96