comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Mixing Ada and C++. Is a good idea?
Date: 1997/11/20
Date: 1997-11-20T00:00:00+00:00	[thread overview]
Message-ID: <dewar.880074788@merv> (raw)



Joe Gwinn says

<<That's what all language folk say, for all languages.

Details aside, simpler is usually better, for all languages.  I don't
doubt that some probelms have been solved, but the history of
inter-language bindings isn't exactly smooth.  Pardon me if I don't
believe that Ada95 is any different in this.

Joe Gwinn
>>


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






             reply	other threads:[~1997-11-20  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-20  0:00 Robert Dewar [this message]
1997-11-21  0:00 ` Mixing Ada and C++. Is a good idea? Larry Kilgallen
1997-11-21  0:00   ` Robert Dewar
1997-11-24  0:00 ` Anonymous
  -- strict thread matches above, loose matches on Subject: below --
1997-11-04  0:00 Arantza Diaz de Ilarraza
1997-11-11  0:00 ` Joe Gwinn
1997-11-12  0:00   ` Robert Dewar
1997-11-14  0:00   ` Ed Falis
1997-11-14  0:00     ` Joe Gwinn
1997-11-14  0:00       ` Robert Dewar
1997-11-14  0:00       ` Robert Dewar
1997-11-20  0:00         ` Joe Gwinn
1997-11-15  0:00   ` Matthew Heaney
1997-11-20  0:00     ` Joe Gwinn
1997-11-21  0:00       ` Robert Dewar
1997-11-21  0:00         ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox