(Sebesta, 2000) Considere o programa BIGSUB
apresentado a seguir:
program BIGSUB;
var
GLOBAL : integer;
LIST : array[1..2] of integer;
procedure SUB(PARAM : integer);
begin
PARAM := 3;
GLOBAL := GLOBAL + 1;
PARAM := 5;
end;
begin
LIST[1] := 3;
LIST[2] := 1;
GLOBAL := 1;
SUB(LIST[GLOBAL]);
end.
Execute manualmente o novo programa sob as mesmas pressuposições e compare os valores resultantes do array LIST
em BIGSUB
depois do retorno de SUB
:
Variável | Inicial | SUB(LIST[GLOBAL]) |
---|---|---|
LIST[1] | 3 | 3 |
LIST[2] | 1 | 1 |
GLOBAL | 1 | 1 2 |
PARAM | 3 3 5 |
Variável | Inicial | SUB(LIST[GLOBAL]) |
---|---|---|
LIST[1] | 3 | 3 3 5 |
LIST[2] | 1 | 1 |
GLOBAL | 1 | 1 2 |
PARAM | LIST[1] |
Variável | Inicial | SUB(LIST[GLOBAL]) |
---|---|---|
LIST[1] | 3 | 3 3 |
LIST[2] | 1 | 1 5 |
GLOBAL | 1 | 1 2 |
PARAM | LIST[GLOBAL] |
Variável | Inicial | SUB(LIST[GLOBAL]) |
---|---|---|
LIST[1] | 3 | 3 5 |
LIST[2] | 1 | 1 |
GLOBAL | 1 | 1 2 |
PARAM | 3 3 5 (LIST[1]) |
Sebesta, Robert W. (2000). Conceitos de Linguagens de Programação. 4ª edição. Porto Alegre: Bookman. 624 páginas.