Conformant Arrays in C

Richard A. O'Keefe ok at quintus.UUCP
Tue Feb 23 08:20:52 AEST 1988


In article <2336 at umd5.umd.edu>, chris at trantor.umd.edu (Chris Torek) writes:
> In article <676 at cresswell.quintus.UUCP> ok at quintus.UUCP
> (Richard A. O'Keefe) writes:
> >Background:
> >	David Hough sent me his comments on dpANS C.
> >	He wants a language which can do at least as much as Fortran could.
> >
> >	One of his criteria was that you should be able to write
> >	subroutines that handle multi-dimensional arrays sensibly.
> 
> I would claim that the `best' way to do this is to use the row-vector
> approach.  To create a two-dimensional array, e.g., do the following:
> This does, of course, require more memory to describe, but row vectors
> are generally faster anyway.  Since the whole matrix is still there
> as a single block of memory, you can use existing routines as well
> (by passing m->m2_data).
> 
> So why is this solution insufficient?

I like the approach Torek recommends, having met this approach on the
B6700.  But the sad fact of the matter is that C doesn't support it.
C *will* let you do it yourself, but it *won't* do it for you.
Torek's own example is a better illustration of how much *work* it is
to use this approach in C than I could have come up with, and the
result doesn't look much like ordinary array access in C.  The point
of the conformant array suggestion is that
 o it is a proven technique
 o for hacking around a basic design flaw in Pascal that is also present in C
 o it lets you use array parameters *directly* 

Torek is absolutely right that "row vectors" are a very sensible
implementation technique, but having the machinery show through is
not a sensible >language< technique.

I'm sure that something better than conformant arrays can be done.
But we're looking for something that makes it EASY to pass array
parameters and EASY to use them, nearly as easy as passing fixed
size arrays would be.  We're also looking for something which will
be the same for all C programmers:  if I want to pass an array to
a function I got from Fred, and to pass the same array to a function
I got from Joe, I really do *not* want to find out that Fred used
row pointers and Joe used column pointers.



More information about the Comp.lang.c mailing list