functions within functions
David Tanguay
datangua at watmath.waterloo.edu
Sat Feb 9 10:28:35 AEST 1991
One of the "problems" with adding nested functions to C is the addition
of a display to access autos in outer scopes. The whole issue could be
avoided by not having autos imported into functions.
E.g.:
int f( int a )
{
static int b;
auto int c;
int g( int d )
{
b = d+1; /* is okay */
c = 0; /* error: c is not in scope */
return d * b;
}
c = g( a + b );
return 3 * c + 2;
}
/* g is not visible here */
This results in scoping rules similar to Port (a cousin of C -- B->Zed->Port,
I believe).
Additional idea:
an auto function is not visible to inner functions, static function is
--
David Tanguay Software Development Group, University of Waterloo
More information about the Comp.std.c
mailing list