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,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-08 05:55:26 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-039-240.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Wed, 08 Jan 2003 14:55:45 +0100 Organization: At home Message-ID: References: <3E147D79.2070703@cogeco.ca> <4519e058.0301031434.51a0c880@posting.google.com> <3chl1vg7p83jlgcgjndaa8n5lnh11a3l5t@4ax.com> <1041999874.693157@master.nyc.kbcfp.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-039-240.arcor-ip.net (145.254.39.240) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1042034118 16113486 145.254.39.240 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:32750 Date: 2003-01-08T14:55:45+01:00 List-Id: Hyman Rosen wrote: > Dmitry A. Kazakov wrote: >> Shared bodies are working against the C++'s myth about unbeatable >> efficience of templates. > > Do you have any evidence that this is a myth, rather than a fact? No study I know of. However, it is easy to imagine a case when a non-inlined subroutine could be more efficient [in terms of speed] than an inlined one. I do not care about the realism of the following example, but let we have a sort of applet which runs some simple algorithm for many different types. Each time you load it, only one branch for one selected type is executed. If the algorithm is an inlined instance, the time for loading, initialization of the paged memory, symbol relocation etc, could be longer than the time of all dereferences and dispatch. > That is, in the C++ model of generics, the compiler has all the type > information available at the point where it is compiling the code, > so it's hard to see how any other model can be *more* efficient. So > the best you can hope for is to be as efficient. Yes. Only "hope" is IMO a wrong word. I think it is indeed possible to make tagged types as efficient as fully inlined macro expansions, provided that the corresonding class-wide routines are also inlined. > I think of the > canonical case as being std::sort, which can inline comparison between > objects, so sorting an array of integers involves just doing an inline > machine integer compare. > Not only that, but the C++ model allows for specialization, so that the > body of code in question does not all have to come from the same block of > generic code - there can be completely different bodies for different > types. This makes generic sharing even less likely there. My point was: - either we implement generics as macro expansions and then have disadvantages XYZ; - or we share bodies, loosing some power of generics, so that a question arise, why generics and not tagged types? -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de