comp.lang.ada
 help / color / mirror / Atom feed
From: Colin_Paul_Gloster@ACM.org (Colin Paul Gloster)
Subject: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
Date: 29 Jul 2002 12:05:20 GMT
Date: 2002-07-29T12:05:20+00:00	[thread overview]
Message-ID: <slrnakabs0.qhs.Colin_Paul_Gloster@camac.dcu.ie> (raw)

(The Java language advocate in the subject title is not me, and is not so
naive as to suggest that any Java implementations are yet of sufficient
quality to trust an unmanned orbiting craft with, but he hopes they will
be in future. For the record, his preferences include in descending
order: Java; C++; Ada 95; and Ada 83 (so at least he acknowledges that
there is not simply Ada, it was followed by Ada 95.))

Does anyone have any advice on this topic (given that a C++ base of his
which he happily ported to Java used loads of MI though Java does not
support full blown (i.e. implementation too) MI, this expert has dismissed
using Ada 95 for a particular approach he has chosen for which his
solutions have an affinity to MI)? Any alternate ideas to published ideas
quoted below?, or have you come across any rumors that any of these have
been discredited?, or any favorites?

"Experiences in Object-Oriented Programming" (Panel),
S. Barbey (Ed.), first published in Charles B. Engle Jr. (Ed.),
TRI-Ada '95 Conference Proceedings, Anaheim, California, USA, 5-10
November 1995, pp. 194-199, available for free at
http://www.Adahome.com/Resources/Papers/OO/experiences_in_oop.ps.Z and from
HTTP://portal.ACM.org/citation.cfm?id=376572&coll=portal&dl=ACM&CFID=3601926&CFTOKEN=30407690
for a charge mentioned Tucker Taft's examples and later has:

"[..] the claimed usefulness of multiple inheritance. (Ironically the C++
Booch Components had multiple inheritance designed out of them by the time
Stroustrup's book went to print!)"

S. Barbey again individually is someone to have mentioned Tucker Taft's
examples in the rationale, and claimed that an example of a type derived
from Ada.Finalization[Limited_]Controlled where neither its type nor
enclosing type are being controlled too given in the paper is a case where
other languages require multiple inheritance but Ada 95 does not. ("Ada 95
as Implementation Language for Object-Oriented Designs", revised 18
October 1995,
HTTP://WWW.Adahome.com/Resources/Papers/OO/ada95_as_il_for_ood-revised.ps.Z 
.)

Barbey later gave an example of using a generic for using only particular
properties of an object in particular circumstances, which again is
something he believed other languages would encourage multiple inheritance
for.

The paper drew to a close with "We have also shown that multiple
inheritance is not necessary in most cases where it would be needed in
other object-oriented programming languages."

Another reason some desire multiple inheritance is for multiple
classification... "It is intersting to note that, where available,
multiple inheritance (MI) is often used for the purpose of such multiple
classification, i.e. for cases of multiple, cross-referencing
catalogues. But MI is not necessarily the best tool, since for instance a
famous area of dispute is what "repeated inheritance" should
mean. [..]". That quote is from a revised version of Magnus Kempe's
"Heterogeneous Data Structures and Cross-Classification of Objects with
Ada 95" which shows an approach doable in C and used in many C books to
show how linked lists etc. may be implemented.

HTTP://WWW.AdaIC.org/whyada/ada-vs-c/ada-vs-c.html is based on an article
by Edmond Schonberg and dismisses the need for MI, but is not as
comprehensive as some of the material already referenced.

He went in to more detail with Bernard Banner in their TRI-Ada '92
"Assessing Ada 9X OOP" paper.It is archived not many hyperlinks away from
HTTP://portal.ACM.org/citation.cfm?id=143593&coll=portal&dl=ACM&CFID=3601926&CFTOKEN=30407690
Therein they said

"[..] ([..] placing semaphores in a
sequential data structure to insure its correctness in a
multithreaded environment). This is the context in which
multiple inheritance is usually said to be indispensable. Ada
9X only supports single inheritance, and our challenge was
to obtain reasonable factorization and code reuse in its
absence. The object-oriented mechanisms of Ada 9X are
sufficiently rich to make this possible in most cases."

but that

"uses of multiple inheritance to inherit several interfaces cannot be
ruled out
but they seem to be less common and those will be awkward to model in Ada
9X."

For TRI-Ada '94's "Implementing internal program representations with Ada
and Ada 9X", Arthur G. Duncan claimed that there is an MI mapping to Ada
83 which loses compile-time checking, but then came up with an Ada 9X
mapping keeping compile-time checking. See
HTTP://portal.ACM.org/citation.cfm?id=197716&coll=portal&dl=ACM&CFID=3601926&CFTOKEN=30407690
if you do not have it in hardcopy.

In the Java and Ada paper by Ben Brosgol entitled "A comparison of the
object-oriented features of Ada 95 and Java" (TRI-Ada 1997,
HTTP://portal.ACM.org/citation.cfm?id=269652&coll=portal&dl=ACM&CFID=3601926&CFTOKEN=30407690
) there is nothing particularly extra in the MI stakes (though the variety
of approaches in Ada for different aspects is not mentioned, generics are 
presented as if they are the only way) but "Interestingly, Java uses
inheritance (from Object) to simulate generics, whereas Ada uses generics
to simulate multiple inheritance. The languages were opting to avoid
semantic and implementation complexity, but at the cost of some complexity
for the user" is worth a chuckle.

I may also check out "A systematic approach to multiple inheritance
implementation" by J. Templ in "ACM SIGPLAN Notices", Volume 28 ,  Issue 4
(April 1993) which seems to be indexed but archived online at the moment
but it is probably already available to me in hardcopy.

Norman Cohen reported that no compelling reason to include MI in Ada was
found in two workshops... news:8910161521.AA27039@ajpo.sei.cmu.edu ,
16 Oct 89 13:57:09 GMT archived at
HTTP://groups.Google.com/groups?safe=images&ie=UTF-8&oe=UTF-8&as_umsgid=8910161521.AA27039@ajpo.sei.cmu.edu&lr=&hl=en

Tucker Taft posted

"[..]

There are basically three distinct situations associated
with multi-inheritance mixins:

  1) The case where the mix-in provides components
     and operations, and any overriding of these operations
     needs only to look at the components of the mix-in itself.

  2) The case where the mix-in provides components and operations,
     and some of the overriding of these operations needs access
     to the whole object, rather than just the components of the mix-in.

  3) Like (2), and in addition, any object with the mix-in must
     be able to be linked onto a list (or into some similar 
     heterogeneous data structure) of other objects with the same mix-in.

Case (1) is handled completely in Ada 9X by a record or private extension,
with the type being mixed in (in a possibly extended form) as a 
component of the record extension.

Case (2) is handled with a generic, that takes any type in
a given class (formal derived type), adds components (via extension) 
and operations, and then reexports the extended type.  The new operations
have access to the whole object, not just to the components
being added.

Case (3) is handled with an access discriminant, that provides
access to the enclosing object for the operations of the mix-in,
while still allowing links through the mix-in.  Generics can
also be used to simplify the definition.

[..]"

on 11 Sep 92... news:1992Sep11.182034.26753@inmet.camb.inmet.com ,
http://groups.google.com/groups?safe=images&ie=UTF-8&oe=UTF-8&as_umsgid=1992Sep11.182034.26753@inmet.camb.inmet.com&lr=&hl=en
.

Hyman Rosen may be particualrly expert in pointing out what MI in C++
boasts over Ada. ("I [Hyman Rosen] can't speak for anyone else, but I use
C++ because I love it. I am at my current job because I answered an ad
which was looking for expert C++ programmers, and it sounded (and
is) exactly like what I wanted. I find the combination of multiple
inheritance, [..] to result in remarkably concise, expressive, efficient,
and typesafe code which is moreover a lot of fun to write. It more than
makes up for the warped C-legacy syntax.", news:3D0DF19E.5010805@mail.com )


Thanks for feedback and pointers and hearsay.



             reply	other threads:[~2002-07-29 12:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-29 12:05 Colin Paul Gloster [this message]
2002-07-29 12:42 ` Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate? Jean-Pierre Rosen
2002-07-29 14:18   ` Colin Paul Gloster
2002-07-29 14:58     ` Jean-Pierre Rosen
2002-07-29 17:04       ` Pascal Obry
2002-07-30 13:57   ` Hyman Rosen
2002-07-30 14:27     ` Jean-Pierre Rosen
2002-07-30 15:30       ` Hyman Rosen
2002-07-30 17:34         ` Jim Rogers
2002-07-30 18:20           ` Hyman Rosen
2002-07-30 20:22             ` Robert A Duff
2002-07-30 19:17           ` Robert A Duff
2002-07-30 22:10             ` Hyman Rosen
2002-07-29 17:27 ` Hyman Rosen
2002-07-30  8:13   ` Dmitry A. Kazakov
2002-07-30 20:55     ` Robert Dewar
2002-07-31 22:08       ` Dmitry A.Kazakov
replies disabled

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