C subscripts

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Fri Nov 2 17:17:27 AEST 1984


> ... however I see problems with array[sub,sub]. Specificly
> passing arrays a parameters would have to allow some way for the procedure
> to know the size of the various dementions to compute the index of elements
> of the array correctly. This is difficult in a losely typed language like C.
> I think that pointers would have a similar problem.

There is already a problem with using variable-sized arrays as
parameters to C functions.  This could be solved in the obvious
way (`a la Fortran) without breaking any existing code, but
there has been a remarkable lack of enthusiasm for the idea when
it has been suggested to members of the ANSI C committee.  As
things now stand, array parameters must have CONSTANT dimensions
specified for all but the first subscript.  To have them
determined dynamically at run-time (without being also passed in
as parameters), a mechanism known as "templates" or "dope vectors"
is required.  This is too much complexity for C's intended purpose.



More information about the Comp.lang.c mailing list