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,95d036084078aa89 X-Google-Attributes: gid103376,public From: fjh@cs.mu.oz.au (Fergus Henderson) Subject: Re: Compiling, binding, and linking an Ada prog. interfaced with C Date: 1998/08/02 Message-ID: <6q28po$42j$1@mulga.cs.mu.OZ.AU>#1/1 X-Deja-AN: 377248835 References: <1998072706002200.CAA02664@ladder01.news.aol.com> <35BD28BF.A5B@atlas.otago.ac.nz> <6pn02g$2ue$1@mulga.cs.mu.OZ.AU> Organization: Computer Science, The University of Melbourne Newsgroups: comp.lang.ada Date: 1998-08-02T00:00:00+00:00 List-Id: dewar@merv.cs.nyu.edu (Robert Dewar) writes: ><< > This is one respect in which Ada's otherwise excellent C interface > > features are not quite as good as those of Mercury or ISE Eiffel, > > which both allow you to import C macros without having to write a > > separate C file containing glue code. >>> > >Obviously "importing" C macros in full generality would mean inporting >the full syntax and semantics of C into the parent language, not something >that is remotely feasible at the language definition level if you ask me. On the contrary, it is quite feasible. Those syntax and semantics can be imported "by reference", so there's no significant increase in the complexity of the language or the length of the language standard. It can be implemented without requiring the Ada compiler to understand or even parse C syntax. >Sure a given implementation may be able to rig something up (e.g. if it >translates into C anyway). As it happens, both ISE Eiffel and Mercury translate to C. That's probably what prompted us to invent the feature in the first place. But the feature can be implemented quite easily even in an implementation that does not normally translate to C. For example, something that we plan for a future release of Mercury is an interface to C++ macros. Our compiler does not compile to C++ and nor do we plan to make it do so. Rather, we'll just get it to spit out a few C++ code fragments for the `pragma import("C++ macro", ...)' declarations, if any, and pass them to a C++ compiler, while for the remainder of the Mercury module being compiled we will generate C code as usual. Yes, this implementation technique for interfacing with C (or C++) macros will only work if you have a C (resp. C++) compiler around. That is not a drawback, since if you need to interface with C (resp. C++) macros you're going to need that anyway, regardless of whether your Ada (or Eiffel, or Mercury) compiler generates the interfacing stubs automatically or whether you have to write them by hand. And generally when doing inter-language interfacing you do have compiler for both languages available anyhow. -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.