comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Inheritance versus Generics
Date: 1997/04/25
Date: 1997-04-25T00:00:00+00:00	[thread overview]
Message-ID: <E975r0.FIz.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 33601924.774@flash.net


Craig Smith (cdsmith0@flash.net) wrote:

: Generics were a very power feature of Ada-83.  With the OO features
: introduced into Ada-95 (in particuliar, the tagged record and ability to
: inherit), are Generics obsolute?  I would guess since several features
: were added to generics (like generic formal package parameters), the
: answer is no.  Does anyone have any thoughts on this?

This one should get a lot of responses...

Inheritance is good for building an extensible abstraction,
whereas a generic is good for building a parameterized abstraction.

The distinction between extension and parameterization is fundamental
in my view, and both are very useful.

It is interesting to look at Java, which supports only extension --
no parameterization.  You can't build a compile-time-type-safe container 
abstraction in Java, such as a list of T, or a dictionary mapping
T1 to T2, without writing a separate one for each possible T, or each
possible T1/T2 combination.  In Java, you end up using the univeral
"java.lang.Object" class for many things, allowing you to create
heterogenous "bags" of anything, but similarly providing no compile-time
guarantee that a given "bag" has only what you want in it.

By the way, our Ada 95 => Java byte code compiler supports both
generics and extension, since generics are basically a compile-time
concept, and we are only using the Java run-time model, not its
compile-time model.  I might say, when I am feeling a bit unfair, 
that Java has an elegant run-time model dressed in an impoverished 
surface syntax.

: Craig D. Smith

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




  parent reply	other threads:[~1997-04-25  0:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-24  0:00 Inheritance versus Generics Craig Smith
1997-04-25  0:00 ` Lionel Draghi
1997-04-25  0:00 ` Mats Weber
1997-04-27  0:00   ` Matthew Heaney
1997-04-27  0:00     ` Robert Dewar
1997-04-28  0:00       ` Bertrand Meyer
1997-05-03  0:00         ` Robert A Duff
1997-05-03  0:00           ` Robert Dewar
1997-05-03  0:00         ` Jon S Anthony
1997-05-04  0:00           ` Robert Dewar
1997-04-29  0:00     ` bertrand
1997-04-29  0:00       ` Robert Dewar
1997-04-25  0:00 ` Tucker Taft [this message]
1997-04-25  0:00 ` Robert A Duff
1997-04-25  0:00 ` Robert Dewar
1997-04-25  0:00   ` Michael F Brenner
1997-04-25  0:00     ` Robert Dewar
1997-04-27  0:00       ` Nick Roberts
1997-04-29  0:00         ` Michael F Brenner
1997-05-02  0:00           ` John G. Volan
1997-05-02  0:00           ` Nick Roberts
1997-05-03  0:00             ` Robert Dewar
1997-04-29  0:00       ` Mats Weber
1997-05-01  0:00         ` Robert Dewar
1997-04-26  0:00   ` Michael Feldman
1997-04-28  0:00 ` Martin Lorentzon
  -- strict thread matches above, loose matches on Subject: below --
1997-04-27  0:00 tmoran
1997-05-03  0:00 tmoran
replies disabled

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