Forward declarations in function prototypes, yet again

Bruce Blodgett uunet!apollo.hp.com!blodgett
Fri Jul 17 12:41:09 PDT 1992


In C, the declaration of a struct tag with no body exists solely to
make that name visible in the current scope.  A couple of analogous
syntaxes for forward declarations in function prototypes (that I have
seen, but don't recall whom to credit) are:

/* new storage class "forward" here */
		int f1( forward int n; int a[n], int n );

Or if it is too terrible to add any new keywords to the language:
		int f1( int n; int a[n], int n );

It has been pointed out that these forms are ugly, verbose, and
nonintuitive to the reader.  However, if one require this new feature
only where formal parameter n appears lexically after array a, one
would almost always see in actual practice:

/* no forward declaration needed here */
		int f2( int n, int a[n] );

The bottom line is that those who want "declare before use" would use
this latter form, yet the forward declaration would satisfy the needs
of those who cannot or will not rearrange the order of their
parameters.  If someone wants an unambiguous LALR(1) formal grammar
for this proposal, get back to me.

Bruce Blodgett
blodgettaapollo.hp.com
(508) 436-4037



More information about the Numeric-interest mailing list