comp.lang.ada
 help / color / mirror / Atom feed
* Mixing Ada and C++. Is a good idea?
@ 1997-11-04  0:00 Arantza Diaz de Ilarraza
  1997-11-11  0:00 ` Joe Gwinn
  0 siblings, 1 reply; 16+ messages in thread
From: Arantza Diaz de Ilarraza @ 1997-11-04  0:00 UTC (permalink / raw)



Hello

	First: Sorry because my english is very poor!! I am learning so be
patient please ;). Second: the problem. I wish make a program mixing C++
libraries and Ada packages. The mixture will be total: the C++ side will
call some Ada functions and the Ada side will call some C++ methods.Is a
good idea? Can I share data structures between then two sides?
	Another factor is that I am using object-oriented programation in two
sides. I must import and export all methods or can I export all then
class from one side to another?.

				Thank for the response.


Aitor Maritxalar
University of the Basque Country




^ permalink raw reply	[flat|nested] 16+ messages in thread
* Re: Mixing Ada and C++. Is a good idea?
@ 1997-11-20  0:00 Robert Dewar
  1997-11-21  0:00 ` Larry Kilgallen
  1997-11-24  0:00 ` Anonymous
  0 siblings, 2 replies; 16+ messages in thread
From: Robert Dewar @ 1997-11-20  0:00 UTC (permalink / 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






^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~1997-11-24  0:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-04  0:00 Mixing Ada and C++. Is a good idea? 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
  -- strict thread matches above, loose matches on Subject: below --
1997-11-20  0:00 Robert Dewar
1997-11-21  0:00 ` Larry Kilgallen
1997-11-21  0:00   ` Robert Dewar
1997-11-24  0:00 ` Anonymous

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