comp.lang.ada
 help / color / mirror / Atom feed
* Difference between C++'s templates and Ada's generic units
@ 1998-01-26  0:00 Samir N. Muhammad
  1998-01-26  0:00 ` Steve Doiel
  1998-01-26  0:00 ` Brian Rogoff
  0 siblings, 2 replies; 4+ messages in thread
From: Samir N. Muhammad @ 1998-01-26  0:00 UTC (permalink / raw)



Hello everybody,

Would someone explain whether there is a difference between C++'s templates
and Ada's generic units. I checked the WEB document by David Wheeler, 
"Ada,C,C++, and Java vs. The Steelman", and found out that the only difference
is that C++'s templates are not yet standardized. Are there any essential 
differenes between C++ and Ada support for generic programming.




Thanks in advance
Samir Muhammad 






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Difference between C++'s templates and Ada's generic units
  1998-01-26  0:00 Difference between C++'s templates and Ada's generic units Samir N. Muhammad
  1998-01-26  0:00 ` Steve Doiel
@ 1998-01-26  0:00 ` Brian Rogoff
  1 sibling, 0 replies; 4+ messages in thread
From: Brian Rogoff @ 1998-01-26  0:00 UTC (permalink / raw)




On 26 Jan 1998, Samir N. Muhammad wrote:

> Hello everybody,
> 
> Would someone explain whether there is a difference between C++'s templates
> and Ada's generic units. I checked the WEB document by David Wheeler, 
> "Ada,C,C++, and Java vs. The Steelman", and found out that the only difference
> is that C++'s templates are not yet standardized. Are there any essential 
> differenes between C++ and Ada support for generic programming.
> 
> 
> 
> 
> Thanks in advance
> Samir Muhammad 

Hi Samir,
	There are numerous differences between the two. As I haven't 
used C++ templates for a while, I can't comment on many of the changes 
that occurred recently, so check your ISO draft document. Some of the 
most important differences to me are 

(1) C++ supports only unconstrained genericity (no constraints on generic 
    parameters), Ada supports both constrained and unconstrained
    genericity. You can fake constraints in C++, but its very ugly.

(2) C++ does some automatic instantiation of templated functions, all 
    Ada instantiation is explicit. Indeed, C++ can do arbitrary
    computations during template expansion, the so called "template
    metaprogramming". I like the first, and wish Ada allowed some
    automatic instantiation of generics, but feel the other stuff beyond 
    that is too much like macros.

(3) Ada generic units can be separately compiled and are type checked at
    compile time. 

(4) Ada's null bodied generic package specs and sharing constraints on 
    formal package parameters allow an "ML-like" programming style. 
    Barnes' book and the Ada 95 Rationale have some nice examples. 

(5) Functions and procedures can be used as generic parameters in Ada.
    You'd have to fake this by wrapping your function in a class in C++. 

....

There are lots more, but these should be enough to convince you that the 
differences go beyond the issue of standardization alone! In fact, C++ is 
almost a standard, so these documents should soon be revised.

-- Brian





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Difference between C++'s templates and Ada's generic units
  1998-01-26  0:00 Difference between C++'s templates and Ada's generic units Samir N. Muhammad
@ 1998-01-26  0:00 ` Steve Doiel
  1998-01-26  0:00 ` Brian Rogoff
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Doiel @ 1998-01-26  0:00 UTC (permalink / raw)




Samir N. Muhammad wrote in message <6ai045$50p40@beaker.nit.gwu.edu>...
>Hello everybody,
>
>Would someone explain whether there is a difference between C++'s templates
>and Ada's generic units. I checked the WEB document by David Wheeler,
>"Ada,C,C++, and Java vs. The Steelman", and found out that the only
difference
>is that C++'s templates are not yet standardized. Are there any essential
>differenes between C++ and Ada support for generic programming.
>
While I haven't done a lot of programming with C++'s templates, or much with
Ada's generics, I can say that Ada's generics are simpler to use.

My experience with C++ templates was frustrating.  While using a standard
class library I didn't override a virtual function that I was supposed to.
The result
was a compile time error deep inside the template code.  It was very
difficult to
interpret and find the source of the problem.

My experience with Ada's generics was far less frustrating.  All of my
compile
time errors appeared in my generic spec module (imagine that!).

SteveD






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Difference between C++'s templates and Ada's generic units
@ 1998-01-26  0:00 Samir N. Muhammad
  0 siblings, 0 replies; 4+ messages in thread
From: Samir N. Muhammad @ 1998-01-26  0:00 UTC (permalink / raw)



Hello everybody,

Would someone explain whether there is a difference between C++'s templates
and Ada's generic units. I checked the WEB document by David Wheeler,
"Ada,C,C++, and Java vs. The Steelman", and found out that the only difference
is that C++'s templates are not yet standardized. Are there any essential
differenes between C++ and Ada support for generic programming. Any help
is highly appreciated.


Thanks in advance
Samir Muhammad




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-01-26  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-26  0:00 Difference between C++'s templates and Ada's generic units Samir N. Muhammad
1998-01-26  0:00 ` Steve Doiel
1998-01-26  0:00 ` Brian Rogoff
  -- strict thread matches above, loose matches on Subject: below --
1998-01-26  0:00 Samir N. Muhammad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox