No subject

uunet!homxb.att.com!wilber uunet!homxb.att.com!wilber
Thu Dec 19 11:28:00 PST 1991


Subject: Re: Variable-length arrays

>> % [peter s]
>> % I agree.  Certainly the whole point is to make life easier for the
>> % programmer, isn't it?
>>
>> [richard s]
>> You sure feel free to spend my time, don't you?
>
>Peter, if you become a KSR customer, you can feel free to spend my time
>to the full limit of your checkbook <grin>.
>
>the-customer-is-always-right-or-at-least-until-they're-broke-ly y'rs
>   - tim

I think I have discerned the fundamental problem with this discussion --
the compiler writers outnumber the compiler users!  (1/2 :-))

One argument that has been made against

	foo(double a[n], int n) {...}

is, "while this may seem natural for Fortran users, C programmers won't like
seeing `n' used before it is declared."

Well, speaking as a C/C++ programmer who hasn't hacked Fortran in over 10
years, I'd much rather use the above syntax than any of the alternatives that
have been proposed.  Yes, this is inconsistent with the usual rules for
declarations in C but if this thread has made anything clear it's that *any*
scheme for combining standard C function declarations with variable sized
arrays is going to require some degree of bogosity.

This is a relatively benign sort of "use before declaration" because in
practice even the biggest function headers will fit on a 24 line screen.  It's
not as though the poor programmer is going to have to search all over a 5000
line file for the declaration of `n'.  (Before the flames begin, note that I am
*not* saying that the compiler should make any assumptions about how long a
function header can be.)

Bob Wilber



More information about the Numeric-interest mailing list