From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2e11aa5522d5cc28 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Mixing Ada and C++. Is a good idea? Date: 1997/11/20 Message-ID: #1/1 X-Deja-AN: 291118811 X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 880075349 14667 (None) 128.122.140.58 Organization: New York University Newsgroups: comp.lang.ada Date: 1997-11-20T00:00:00+00:00 List-Id: Joe Gwinn says <> No, that's plain wrong. I can only guess it comes from a lack of familiarity with Ada 95. In fact Ada 95 is quite different from other languages in this respect, I have no idea what silly things people do or do not say about languages, but Ada 95 is quite unique among standardized languages in paying considerable attention to providing high level language features at an appropriate level of abstraction for interfacing to C, Fortran, and COBOL in the standard. I am almost certain that Joe is simply unfamiliar with these features, and we can pardon him for not knowing Ada 95, but I don't think we can pardon him for making plainly incorrect statements based on this ignorance :-) For example, the declaration for a record type X pragma Convention (C, X); that says "lay this record out exactly the way C would lay it out", has no analog in any other standardized language (actually I don't know of *any* language in which it has an anolog, but surely among the hundreds of non-standard languages there must be similar examples). Joe, I really think you should take the time to read chapter 13 and annex B of the reference manual to see if your statement seems supportable *to you* once you know the facts. I am perfectly sympathetic to your experiences of difficulties in this area, they are very common. I am even sympathetic to your induction that Ada must be no different, but unfortunately, Ada is the exception that proves the rule here (yes, yes, I know that is not what this phrase means :-) Once on comp.lang.cobol, someone asked how to portably interface between COBOL and C, and basically the answer, from many contributors, was that there was no way. I pointed out that there was a way, although a vey peculiar one. By writing glue code in Ada 95, it is possible to write a tri-lingual program containing Ada, COBOL, and C units, since the interface between Ada and COBOL is well defined and the interface between Ada and C is well defined. For instance here is the code to convert a recvord from the storage format used by C to the storage format used by COBOL. type x is record ... ... end record; type y is new x; pragma Convention (C, X); pragma COnvention (COBOL, Y); VX : X; VY : Y; VX := X (VY); -- convert from COBOL format to C format Robert Dewar Ada Core Technologies