Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!decvax!ucbvax!agate!ig!uwmcsd1!bbn!rochester!PT.CS.CMU.EDU!IUS1.CS.CMU.EDU!edw From: edw@IUS1.CS.CMU.EDU (Eddie Wyatt) Newsgroups: comp.lang.c Subject: Re: Conformant Arrays in C Message-ID: <973@PT.CS.CMU.EDU> Date: 26 Feb 88 15:30:24 GMT References: <42529@sun.uucp> <7297@brl-smoke.ARPA> <676@cresswell.quintus.UUCP> <694@cresswell.quintus.UUCP> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 46 Keywords: ANSI C, C++ > > 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@ius1.cs.cmu.edu