Variable-length arrays

uunet!cup.portal.com!pls uunet!cup.portal.com!pls
Sat Dec 21 11:50:29 PST 1991


I confess I don't understand the problem with
   float f(double a[n], int n);

The claim is made that this is an unnatural syntax for C programers because it
uses n before it's declared. I don't agree. At least, I have no such
expectation and I claim that those who do are wrong.

This is the same problem that gets programmers into trouble with
   i = 3;
   f (i, i++);

Function arguments are NOT processed left to right. The order of processing is
undefined and cannot be depended on.

Now, I'm not sure whether this principle should be used to allow the first
syntax, because you can't say that n is used before defined, or to disallow it
because you can't say that n is defined before it's used.

My own opinion is that I like this proposal. It will appear natural to a
fortran programmer and is clearly the simplest, to the programmer, of any
of the proposals.

    ++PLS



More information about the Numeric-interest mailing list