home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d183
/
pcq.lha
/
PCQ
/
Examples
/
Nests.p
< prev
next >
Wrap
Text File
|
1989-02-26
|
1KB
|
50 lines
program Nests;
{ This program demonstrates that, to some extent, nested
procedures do seem to work. The compiler will accept them
just fine, but does not always produce the right code. The
only problems, as mentioned in the docs, are that 1) you
might end up with duplicate ID's in the assembly output, and
2) when you try to access a local variable of a parent
procedure or function, the compiler gets the proper offset,
but uses the activation frame of the current procedure, rather
than its parent, as it should. }
var
first : Integer;
procedure outermost;
var
first : char;
procedure inner;
var
first : short;
procedure innermost;
var
first : integer;
begin
first := 42;
writeln('In innermost, first = ', first);
end;
begin
first := 67;
innermost;
writeln('In inner, first = ', first);
end;
begin
first := 'r';
inner;
writeln('In outermost, first = ', first);
end;
begin
first := 78;
outermost;
writeln('In main program, first is ', first);
end.