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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d575f572a099528 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-09 11:36:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!not-for-mail From: Richard Riehle Newsgroups: comp.lang.ada Subject: Re: What is faster Ada or C? Date: Sun, 09 Dec 2001 11:32:26 -0800 Organization: AdaWorks Software Engineering Message-ID: <3C13BC4A.1C1EBE8B@adaworks.com> References: <9ujh51$k6m$1@wanadoo.fr> <3C0EF345.47BCC09@adaworks.com> <568ede3c.0112071202.56fc9f@posting.google.com> Reply-To: richard@adaworks.com NNTP-Posting-Host: 9e.fc.c5.cd Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 9 Dec 2001 19:35:57 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:17650 Date: 2001-12-09T19:35:57+00:00 List-Id: Hyman Rosen wrote: > In C++ it is perfectly legal to separate the declaration of a function > from its implementation, even when it's inline: > > struct a { int twice(int x); }; > inline int a::twice(int x) { return 2 * x; } Unless something has changed, C++ requires the full definition of the inlined function at the place where it is declared. Stroustrup does make a little exception for this in his note about the "absence of unusually clever compilation and linking facilities" (The C++ Programming Language, Third Edition, page 144). At present, the most compilers require full definition in the header file. > Any code which wants to call the function must arrange to see the definition, > which is usually done through an #include. In Ada, the compiler can manage to > find the definition on its own, because of the library system, but that's not > exactly "separate compilation". Well, actually, it is separate compilation. Of course, if one chooses to use some new definition of separate compilation, so be it. Ada permits the designer to specify a declaration in the package specification as inlined: package Not_C_Plus_Plus is procedure Friendly_Inline; pragma Inline(Friendly_Inline); -- no full definition required or permitted end Not_C_Plus_Plus; This specification is compiled independently of its implementation. If we really want to defer the implementation to another separate compilation, we could, package body Not_C_Plus_Plus is procedure Friendly_Inline is separate; end Not_C_Plus_Plus; thereby separating the compilation of the [definition of] the implementing code to yet another separate subunit. separate (Not_C_Plus_Plus) procedure Friendly_Inline is begin -- algorithmic implementation end Friendly_Inline; The library unit model of Ada, along with its many facilities for separate compilation are one of the useful features of the language. In fact, Ada's separate compilation helps maintain consistency across multiple library units when development is being performed by multiple programmers. The need for a #include, along with associated compiler directives in C++ is not as robust a model for preserving unit integrity as the Ada model, even though the C++ model does have some offsetting advantages under some circumstances. Richard Riehle