From: Peter C. Chapin on 26 Jul 2010 20:51 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
From: Gene on 26 Jul 2010 23:01 On Jul 26, 8:51 pm, "Peter C. Chapin" <pcc482...(a)gmail.com> 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.
From: AdaMagica on 27 Jul 2010 02:55 As far as I understand, GNAT replicates, RR shares generic code. (Don't know about IBM (former Rational).)
From: Martin on 27 Jul 2010 06:51 On 27 July, 01:51, "Peter C. Chapin" <pcc482...(a)gmail.com> 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 Allowed yes, required no. -- Martin
From: Ludovic Brenta on 27 Jul 2010 07:29
AdaMagica writes: > As far as I understand, GNAT replicates, RR shares generic code. > (Don't know about IBM (former Rational).) My understanding is similar; indeed, Janus/Ada is the only compiler that shares generics. Unfortunately, no compiler offers the option to choose; this is an implementation decision. -- Ludovic Brenta. |