variable length arrays and function definitions, revised

Thomas M. Breuel uunet!ai.mit.edu!tmb
Fri Dec 20 10:56:51 PST 1991


Richard Stallman writes:
 > Cray has proposed extending the language to permit the following:
 > 
 >     int
 >     foo (double a[n], int n)
 >     { ... }
 > 
 > This looks seductively natural, but is painful to implement and
 > violates a basic principle of C, which is that the scope of a
 > declaration starts where it is written.  It requires half-parsing
 > `a[n]' before the declaration of `n' has even been seen.

I don't understand why this is hard to implement. An identifier in
square brackets can only denote an object of integral type giving one
of the dimensions of an array. This can be parsed completely without
knowing how, or even whether, the identifier will be defined somewhere
else in the argument list.

It seems to me that which particular integral type the identifier has,
or whether it is an identifier in global scope (maybe an enum) is then
a semantic issue that can be resolved easily after the argument list
has been parsed.

So, what is the problem exactly?

					Thomas.




More information about the Numeric-interest mailing list