Inheritance and Ada (and access types and generics) 
Author Message
 Inheritance and Ada (and access types and generics)

Quote:

> I am surprised none of the discussants quoted my article, ``Genericity
> versus Inheritance'', which addresses precisely this topic. The paper
> was published in the Proceedings of the first OOPSLA conference
> (OOPSLA 86, Portland; SIGPLAN Notices, 21, 11, pp. 391-405). A revised
> version is due for publication in the Journal of Pascal, Ada and Modula-2.

>    The article explores the relationship between Ada-like generic modules
> and inheritance as it exists in O-O languages. It shows the respective
> benefits of both techniques and explains how they have been (cleanly,
> I think) combined in the Eiffel language and environment.

My apologies, I was at OOPSLA '86 and thought your paper was
excellent.  (and there have been other good papers on the subject as
well.)

Quote:
> This does not prevent data structures from being polymorphic:
> for example, if an entity is declared as

>            fs: STACK [FIGURE]

> then you may push onto the corresponding object a point,
> a circle etc., assuming POINT, CIRCLE
> etc. are descendant classes (in the sense of inheritance) of FIGURE.
> However you may not push onto fs, say, an integer....

Actually, attempting to simulate this kind of polymorphism in Ada is
even clumsier than your paper portrayed it.  As you pointed out, you do
end up having to define variant record types (whose variants include
all the polymorphic subclasses) and other case analyses all over the
place.  

Even worse, however, Ada does not let you instantiate the (generic)
STACK package with an unconstrained variant record type, if the
package requires the type to be constrained (as is often the case).
Thus in Ada, I find I am continually forced to play this game of
instantiating the generic with an access (pointer) type to the variant
record type.  Not only is this clumsy, but it requires you to use
allocators ("new") to create the instances of the record type, opening
up all the performance issues of using dynamic allocation in embedded
computer systems software.

Sadly, you are often forced to use access types in Ada, even when
you're not particularly interested in dynamic storage, but just to get
around some of the quirks of Ada's type model.  Another example:  you
can't instantiate a generic with an incomplete type.  So you end up
having to fake it by instantiating the generic with an access type
that points to the incomplete type, and you can guess the rest.

Steven Litvintchouk
MITRE Corporation
Burlington Road
Bedford, MA  01730

Fone:  (617)271-7753

UUCP:  ...{cbosgd,decvax,genrad,ll-xn,philabs,security,utzoo}!linus!sdl



Wed, 19 May 1993 01:09:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Inheritance of abstract types: accessing the parent type (F2003 standard question)

2. Ada's survival based on accessing C++ libs with inheritance

3. type is access cf type is access all?

4. Inheritance versus Generics

5. Do inheritance types make parametized types redundant?

6. Do inheritance types make parametized types redundant?

7. Help with Ada syntax and access types.

8. C++'s pointer vs Ada's Access type

9. Ada Variant Records/Access Types.....

10. Garbage collector necessary (for Ada access types)?

11. Ada question: access types

12. new C# language features - Generics, Anonymous Methods - Partial Types

 

 
Powered by phpBB® Forum Software