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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73036d0217be91e2 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Inheritance versus Generics Date: 1997/04/25 Message-ID: #1/1 X-Deja-AN: 237285615 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <33601924.774@flash.net> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-04-25T00:00:00+00:00 List-Id: 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