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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e93f73587e2bc1c3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!t11g2000vbj.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Re: Sharing generic bodies across instantiations. Date: Mon, 26 Jul 2010 20:01:24 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4c4e2d69$0$2378$4d3efbfe@news.sover.net> NNTP-Posting-Host: 184.12.82.207 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1280199684 8029 127.0.0.1 (27 Jul 2010 03:01:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 27 Jul 2010 03:01:24 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t11g2000vbj.googlegroups.com; posting-host=184.12.82.207; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:12594 Date: 2010-07-26T20:01:24-07:00 List-Id: On Jul 26, 8:51=A0pm, "Peter C. Chapin" wrote: > It has been my understanding that Ada's generics are designed in such a > way as to allow implementations to share the code of a generic body > across all the instantiations. I understand that doing this might > involve a performance penalty relative to creating independent code for > each instantiation. However, I can see that there are cases where such > sharing would be desirable. > > Is my understanding still accurate (was it ever accurate), for example > even with Ada 2005? > > Thanks! > > Peter I don't believe this is true. Early compilers replicated code for each instantiation even when they might have been able to share. But I've read that the compiler is free to choose to generate parameterized code that's highly sharable. Yes, in that case the implementation will generate smaller but likely to be slower code. You may be thinking of java templates, which explicitly require that code is shared among all instances. This is much easier in Java due to the reference semantics.