Previous topic | Ada Home Page | Index

Scope example

 1   with TEXT_IO;
 2   procedure nonsense is
 3   
 4       package int_io is new TEXT_IO.INTEGER_IO(INTEGER);
 5       use TEXT_IO, int_io;
 6   
 7       X, Y, Z : integer;
 8
 9       --------------------------------------------------
10       -- silly procedure
11       --------------------------------------------------
12       procedure silly (X : in out integer) is
13           Y : integer;
14       begin -- silly
15           Y := X + 23;
16           Z := X;
17           X := Y;
18           put(X); put(Y); put(Z); new_line;
19       end silly;
20
21   ------------------------------------------------------
22   -- main program
23   ------------------------------------------------------
24   begin -- nonsense
25       X :=  0;
26       Y :=  5;
27       Z := 10;
28       put(X); put(Y); put(Z); new_line;
29       silly (Y);
30       put(X); put(Y); put(Z); new_line;
31   end nonsense;


Visibility

name line silly nonsense
X 7 no yes
Y 7 no yes
Z 7 yes yes
X 12 yes no
Y 13 yes no

Program output


     0     5    10             (before calling silly)
    28    28     5             (in silly)
     0    28     5             (after return from silly)


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