comp.lang.ada
 help / color / mirror / Atom feed
From: bu.edu!inmet!inmet!stt@bloom-beacon.mit.edu
Subject: Re: Multiple Inheritance in Ada 9X
Date: 29 Dec 91 19:38:00 GMT	[thread overview]
Message-ID: <20600129@inmet> (raw)

In article <829@ajpo.sei.cmu.edu>, 
goodsenj@ajpo.sei.cmu.edu (John Goodsen) writes:

> I'm about to develop a comprehensive paper discussing the
> necessity for multiple inheritance to be included into Ada 9X,
> under the request of the mapping/revision team.
> 2 questions:
> 
> 1) Who's done this before (both created the paper AND sent it to the mapping/
>    revision team -- surely I'm not the first).  What were your results (ie.
>    is it a waste of time like so many have told me in the Ada community, or
>    is this a worthwhile effort) ?

We welcome both comments and papers related to the Ada 9X effort.
Unfortunately, we are not able to respond individually to every comment,
though we do read them and try to incorporate what we learn into the
Ada 9X "mapping" proposals.

> 2) Assuming it's not a waste of my efforts, please send me any
>    pertinent information which you feel will need to be included in
>    this paper (personal examples, journal/textbook references, etc.).

We actually posted a request for "real" examples of Multiple Inheritance
on "comp.lang.c++" about a year ago.  We received several responses, but
no "real" examples.  In Eiffel, Multiple Inheritance is used for
essentially all external references between classes.  Ada already has
the "with" clause for establishing external references, and in that
very limited sense already supports multiple inheritance.

What we are interested in is whether it is important to be able
to combine two types to form a third which is an "extension" of both.
By this we mean that the new type incorporates the "state" of the two
parent types, and can be passed to operations which accept either of
the parents.  Of course, where MI gets nasty is when the same ancestor
type is inherited through two different paths.  Complexity arises in
deciding whether to replicate the ancestor state or share part or
all of of it in the descendant type.  Furthermore, if the same
method is defined along both paths, there must be some resolution
rule to select the appropriate method to be inherited in the new
type.  

Eiffel uses renaming to control
replication versus sharing.  C++ uses the concept of "virtual" base
classes to accomplish sharing.  CLOS uses slot names to determine
sharing, plus deterministic ordering rules to select methods.

In any case, it is clear that multiple inheritance can add complexity
to both the implementation (even when not used) and to the user
view of the language.  Multiple inheritance can also be partially
supported through the use of other composition mechanisms (e.g.,
by making one parent a component rather than an ancestor, or by
using the "with" clause approach, or by using generics).
We are interested in examples which show how multiple inheritance
leads to a simpler solution to a realistic problem than that provided by
the other available composition mechanisms.  Such examples
should then help in making the right trade off between expressibility
and language and implementation complexity.

In the most recent public release of the Ada 9X Mapping Specification
(December 1991, Version 4.0 -- available soon on ajpo.sei.cmu.edu),
we do provide building blocks for multiple inheritance, 
but we do not provide direct support.  
It would be particularly useful if examples could be worked
out using the proposed building blocks (see section 3.8.2 of
the Mapping Specification for a description of the building blocks).

For the adventurous, here is a trivial example of multiple
inheritance using the proposed Ada 9X mechanisms:

   -- Root types for Smalltalk-inspired MVC Graphic User Interface
   type Model is tagged limited private;
   type View is tagged limited private;
   type Controller is tagged limited private;

   procedure Add_View(M : in out Model; V : access View'CLASS);
     -- Add a view to a model
   procedure Update_View(V : in out View; M : Model'CLASS);
     -- Update a view when the model changes

   type Window;  -- incomplete type

   type View_Mixin(Win : access Window'CLASS) is 
     new View with limited private;  -- View to be "mixed in" to a window

   type Controller_Mixin(Win : access Window'CLASS) is 
     new Controller with limited private;  -- Controller to be "mixed in"

   type Window is new Basic_Window with record
     -- Window with two mixins
     V : View_Mixin(Window'ACCESS);  -- Discrim points to enclosing window
     C : Controller_Mixin(Window'ACCESS);  -- Discrim points to enclosing win
   end record;

If we have an object "W : Window" then we can pass W.V
to operations on Views, and W.C to operations on Controllers.
These operations can reference the enclosing window object through
the "access discriminant" which has been default initialized to point at W
using the ACCESS attribute.

The forthcoming revised Ada 9X Mapping Rationale (due by end of February)
will contain more such examples, hopefully.

> Thanks in advance -
> 
> 
> John Goodsen
> Products Manager
> SETT, Inc.
> goodsenj@ajpo.sei.cmu.edu

S. Tucker Taft
Ada 9X Mapping/Revision Team    (ada9x-mrt@inmet.inmet.com)
Intermetrics, Inc.
733 Concord Avenue
Cambridge, MA  02138

             reply	other threads:[~1991-12-29 19:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-29 19:38 bu.edu!inmet!inmet!stt [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-01-10 14:48 Multiple Inheritance in Ada 9X mcsun!fuug!news.funet.fi!sunic!ugle.unit.no!nuug!ifi.uio.no!holmenkollen!
1992-01-05 19:54 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!darwin.sura.net!Siriu
1992-01-02 21:31 Dan Weinreb
1991-12-31 11:00 Bob Hathaway
1991-12-30 20:10 Dan Weinreb
1991-12-30 20:01 Dan Weinreb
1991-12-29  6:19 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!think.com!barmar
1991-12-29  0:15 Object Systems
1991-12-27 21:40 Bjarne Stroustrup
1991-12-26 15:29 icd.ab.com!iccgcc.decnet.ab.com!klimas
replies disabled

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