Conformant Arrays in C

Richard A. O'Keefe ok at quintus.UUCP
Sat Feb 27 18:44:23 AEST 1988


In article <973 at PT.CS.CMU.EDU>, edw at IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>   The issue of intercallability procedures is no simple matter.  You
> have to deal with the mapping of data types from one language to the
> next.   A mapping of a data type between languages need not be trivial
> or computational inexpensive.

>    I seem to recall that FORTRASH :-) (or at least some versions) uses column
> major form for storing arrays and C uses row major form.  To move
> multi-dimensional arrays (tensor) from one language to the next
> you must preform a transpose.  This could get expensive for large
> matrices.
> 
>   However, I didn't miss part of what you were advocating which
> was common representation for data types.

I begin to appreciate the problems that X3J11 have faced.

NO!  I was not advocating common representation of data types!
At least, not in the standard as such.
What I was advocating was that the standard should not go out
of its way to PRECLUDE intercallability, which is a different point.

The point about Fortran using column-major and other languages (Algol
60, Pascal, ADA, C, ...) using row-major is a rather old red herring.
So a Fortran subroutine might use MAT(I,J) and the C caller would
identify the exact same element as mat[j][i]. So what?  ADA[*] uses the
same order as C, and nobody seems to think ADA can't interface to
Fortran.  Since one is passing a description of an array to the other
language, the cost of transposing the array proper is not an issue:
what matters is what it costs to pass the description of the transpose.
(I am *not* suggesting that descriptor-passing should be *required* or
that the need for transposition is genuine.)  Similarly, C would use a
fixed lower bound of zero, but Turing would use a constant expression,
and Pascal would be given two bounds.  So what?  Any reasonable
bijection will do, it doesn't have to be the identity.

(By the way, my spinor calculus teacher would kill you for confusing
arrays and tensors.  Fortunately, he's not here.  :-)

The C standard cannot possibly require intercallibility, because it has
no authority over other languages.  All I claim for the conformant
array parameter approach is that it avoids over-specification, and,
since this technique is already in use in other languages, is unlikely
to make intercallability worse, and if any other mechanism were to be
adopted, not *precluding* intercallability is a good criterion.

Someone suggested taking the auxiliary-array-of-pointers approach and
requiring it in the standard library.  That approach may be a wonderful
implementation method, but it is too specific.  (C is already too much
like Lisp, no point in making it worse.)  The worst thing about that
approach is that it requires explicit memory management.  It's great
that C permits explicit memory management, but *requiring* it does not
come under the heading of "acts of kindness".  Why should I have to
explicitly manage a block of pointers to do a trivial thing that
ALGOL 60 did 28 years ago, PL/I does, Pascal does, ... and so on.

Oh well, someone promised me a copy of GNU CC, I guess I'd just better
wait for the other half to arrive, then start hacking.

[*] ADA is a birthmark of the DuD UFO.



More information about the Comp.lang.c mailing list