Conformant Arrays in C

Eddie Wyatt edw at IUS1.CS.CMU.EDU
Sat Feb 27 01:30:24 AEST 1988


> 
> C is not the only language in the world.  It would be so nice to have
> intercallability between ANSI C and ISO Pascal.  It is particularly
> important not to commit to a particular device (such as Chris Torek's
> idea) so that an implementor can provide something which can be connected
> in a sensible fashion to Pascal or Turing or PL/I or even (via a wee bit of
> macro expansion) to Fortran.  If I go to the trouble of coding a simplex
> algorithm in C, and run it on an IBM mainframe, I would like the C vendor
> to have been able to select an implementation of conformant array parameters
> which is compatible with PL/I.  Or if I find that there is a better one
> already there in PL/I, I don't want to have written my program using
> edge-vectors so that I am *guaranteed* incompatibility with everything in
> sight!

  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.

   Unions in C to the language of your choice is one example of
a non-trivial mapping.  Union in C are indiscriminate - you need not
have a tag fields explicitly determining the data type of the 
union.  Because of this you can't determine the equivalent representation
in another language.  Another example would be mapping structures
in C to Fortran.  Fortran doesn't have a niece equivalent.

   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.  Well, let me add why I
don't think this is a good idea - at least not yet and
here's an example why.  I seem to remember Simula  uses row-vector
representation for matrices.  One of the advantages of this
is that the matrix my have dynamic bounds.  A disadvantage
it that indexing becomes more expensives (a couple levels of
indirection per matrix access).  The point being made it that
the choice of data representations is dictated by the 
design goals of the language.  In many cases there are tradeoffs
between flexablity  and efficiency.
-- 

Eddie Wyatt 				e-mail: edw at ius1.cs.cmu.edu



More information about the Comp.lang.c mailing list