Date : Wed, 23 Sep 2009 09:25:07 +0000 (GMT)
From : kranser@... (Steve Fewell)
Subject: Beeb, this was your grandma!
> But there is one Pascal feature I used to miss -- nested
> functions:
>
> function fred(x : Integer; y : Integer) : Integer;
> function jim(y : Integer) : Integer;
> begin
> return y*5;
> end;
> begin
> return (x*2)+jim(y);
> end;
>
> Nothing outside of "fred" can see "jim" -- effectively this
> is like a
> static function, but restricted to a single function rather
> than a
> single module (or Unit in Pascal parlance). Interestingly
> Pascal seems
> to be the only language that supports this...
Well, actually Ada (similar to Pascal in some respects) supports packages,
where types and associated functions can be encapsulated within a package,
and in that package some functions can be made private - so only other functions
inside the package can see them; and others can be made public and exposed
so the rest of the program to use.
So, that is similar to the Pascal feature. I also think that C# has something
similar to this.
Steve.