comp.lang.ada
 help / color / mirror / Atom feed
* Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
@ 2002-07-29 12:05 Colin Paul Gloster
  2002-07-29 12:42 ` Jean-Pierre Rosen
  2002-07-29 17:27 ` Hyman Rosen
  0 siblings, 2 replies; 17+ messages in thread
From: Colin Paul Gloster @ 2002-07-29 12:05 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 12:05 Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate? Colin Paul Gloster
@ 2002-07-29 12:42 ` Jean-Pierre Rosen
  2002-07-29 14:18   ` Colin Paul Gloster
  2002-07-30 13:57   ` Hyman Rosen
  2002-07-29 17:27 ` Hyman Rosen
  1 sibling, 2 replies; 17+ messages in thread
From: Jean-Pierre Rosen @ 2002-07-29 12:42 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]


"Colin Paul Gloster" <Colin_Paul_Gloster@ACM.org> a �crit dans le message news: slrnakabs0.qhs.Colin_Paul_Gloster@camac.dcu.ie...
> (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?
>
>[extensive bibliography deleted]
> Thanks for feedback and pointers and hearsay.
Good opportunity for plug!

I presented a paper at Ada-Europe 2003 titled "Ada, interfaces, and the listener paradigm".
It provides a design pattern for providing all the functionnality of Java interfaces, and can easily be extende to full MI.
It is available from the proceedings (Springer), but I can send it to anybody who's interested.
It is my intent to publish it on Adalog's web site as soon as I get around to it :-)

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 12:42 ` Jean-Pierre Rosen
@ 2002-07-29 14:18   ` Colin Paul Gloster
  2002-07-29 14:58     ` Jean-Pierre Rosen
  2002-07-30 13:57   ` Hyman Rosen
  1 sibling, 1 reply; 17+ messages in thread
From: Colin Paul Gloster @ 2002-07-29 14:18 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
"Good opportunity for plug!

I presented a paper at Ada-Europe 2003 titled "Ada, interfaces, and the listener paradigm".
It provides a design pattern for providing all the functionnality of Java interfaces, and can easily be extende to full MI.
It is available from the proceedings (Springer), but I can send it to anybody who's interested.
It is my intent to publish it on Adalog's web site as soon as I get around to it :-)"

Thanks for the pointer. If that part of the proceedings will be published
in "Ada User Journal" or "Ada Letters" by the next quarter I can wait,
otherwise please send it to me / publicise on c.l.a. when it is put up on
your website.

Merci.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 14:18   ` Colin Paul Gloster
@ 2002-07-29 14:58     ` Jean-Pierre Rosen
  2002-07-29 17:04       ` Pascal Obry
  0 siblings, 1 reply; 17+ messages in thread
From: Jean-Pierre Rosen @ 2002-07-29 14:58 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]


"Colin Paul Gloster" <Colin_Paul_Gloster@ACM.org> a �crit dans le message news: slrnakajlt.2j1.Colin_Paul_Gloster@camac.dcu.ie...
> Jean-Pierre Rosen wrote:
> "Good opportunity for plug!
>
> I presented a paper at Ada-Europe 2003 titled "Ada, interfaces, and the listener paradigm".
> It provides a design pattern for providing all the functionnality of Java interfaces, and can easily be extende to full MI.
> It is available from the proceedings (Springer), but I can send it to anybody who's interested.
> It is my intent to publish it on Adalog's web site as soon as I get around to it :-)"
>
> Thanks for the pointer. If that part of the proceedings will be published
> in "Ada User Journal" or "Ada Letters" by the next quarter I can wait,
> otherwise please send it to me / publicise on c.l.a. when it is put up on
> your website.
>
I am not responsible for these publications, and I don't know if Springer would allow this, therefore I can't answer that question.
(but Springer does allow putting the papers on the author's web site).

In the meantime, I'll send you the paper by private mail.

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 14:58     ` Jean-Pierre Rosen
@ 2002-07-29 17:04       ` Pascal Obry
  0 siblings, 0 replies; 17+ messages in thread
From: Pascal Obry @ 2002-07-29 17:04 UTC (permalink / raw)



"Jean-Pierre Rosen" <rosen@adalog.fr> writes:

> In the meantime, I'll send you the paper by private mail.

I'll be happy to get a copy too.

Thanks,
Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 12:05 Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate? Colin Paul Gloster
  2002-07-29 12:42 ` Jean-Pierre Rosen
@ 2002-07-29 17:27 ` Hyman Rosen
  2002-07-30  8:13   ` Dmitry A. Kazakov
  1 sibling, 1 reply; 17+ messages in thread
From: Hyman Rosen @ 2002-07-29 17:27 UTC (permalink / raw)


Colin Paul Gloster wrote:
> Hyman Rosen may be particualrly expert in pointing out what MI in C++
> boasts over Ada.

Be that as it may, I would like to point out that a lot of the articles
about MI have the tone of "you don't need it, and if you think you do
need it, here's how to program a simulation of it". That's not really
the point, any more than the possibility of maintaining your own tables
of function pointers removes the necessity of implementing dispatching
in the programming language. The question is whether having MI would
allow the expression of certain programming solutions to be easier and
clearer, and without unduly burdening code which doesn't use it. A lot
of that may depend on other aspects of the language, which can interact
sysnergisticly or destrcutively with MI. For C++, I believe MI is
overwhelmingly positive. I don't know what the answer would be for Ada.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x   to satisfy a Java language advocate?
  2002-07-29 17:27 ` Hyman Rosen
@ 2002-07-30  8:13   ` Dmitry A. Kazakov
  2002-07-30 20:55     ` Robert Dewar
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry A. Kazakov @ 2002-07-30  8:13 UTC (permalink / raw)


On Mon, 29 Jul 2002 13:27:42 -0400, Hyman Rosen <hyrosen@mail.com>
wrote:

>Colin Paul Gloster wrote:
>> Hyman Rosen may be particualrly expert in pointing out what MI in C++
>> boasts over Ada.
>
>Be that as it may, I would like to point out that a lot of the articles
>about MI have the tone of "you don't need it, and if you think you do
>need it, here's how to program a simulation of it". That's not really
>the point, any more than the possibility of maintaining your own tables
>of function pointers removes the necessity of implementing dispatching
>in the programming language. The question is whether having MI would
>allow the expression of certain programming solutions to be easier and
>clearer, and without unduly burdening code which doesn't use it. A lot
>of that may depend on other aspects of the language, which can interact
>sysnergisticly or destrcutively with MI. For C++, I believe MI is
>overwhelmingly positive. I don't know what the answer would be for Ada.

It is of course cannot depend on a language.

I believe the answer is yes, however Ada community is yet not ready to
accept this fact.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-29 12:42 ` Jean-Pierre Rosen
  2002-07-29 14:18   ` Colin Paul Gloster
@ 2002-07-30 13:57   ` Hyman Rosen
  2002-07-30 14:27     ` Jean-Pierre Rosen
  1 sibling, 1 reply; 17+ messages in thread
From: Hyman Rosen @ 2002-07-30 13:57 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> It provides a design pattern for providing all the functionnality of Java interfaces

Including cross-casting?

That is, in Java (or C++), if I have class C implements I1, I2
and I have an I1 reference, I can try casting the I1 to an I2,
and if the reference is actually to a C object, the cast works.

The attempts to simulate MI in Ada by using access discriminants
don't handle this, as far as I know.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-30 13:57   ` Hyman Rosen
@ 2002-07-30 14:27     ` Jean-Pierre Rosen
  2002-07-30 15:30       ` Hyman Rosen
  0 siblings, 1 reply; 17+ messages in thread
From: Jean-Pierre Rosen @ 2002-07-30 14:27 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]


"Hyman Rosen" <hyrosen@mail.com> a �crit dans le message news: fXw19.29303$NX5.1749@nwrddc02.gnilink.net...
> Jean-Pierre Rosen wrote:
> > It provides a design pattern for providing all the functionnality of Java interfaces
>
> Including cross-casting?
>
> That is, in Java (or C++), if I have class C implements I1, I2
> and I have an I1 reference, I can try casting the I1 to an I2,
> and if the reference is actually to a C object, the cast works.
>
> The attempts to simulate MI in Ada by using access discriminants
> don't handle this, as far as I know.
>
Yes. Or more exactly, the design pattern provides functions that allow you to get an I1 or I2 view for a C object, and to go back
from an I1 or I2 view back to the original C object.

And you are correct that this is not obvious to achieve. That's what prompted me to make a paper of it!

--
---------------------------------------------------------
           J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr





^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-30 14:27     ` Jean-Pierre Rosen
@ 2002-07-30 15:30       ` Hyman Rosen
  2002-07-30 17:34         ` Jim Rogers
  0 siblings, 1 reply; 17+ messages in thread
From: Hyman Rosen @ 2002-07-30 15:30 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> Yes. Or more exactly, the design pattern provides functions
 > that allow you to get an I1 or I2 view for a C object, and to
 > go back from an I1 or I2 view back to the original C object.
> 
> And you are correct that this is not obvious to achieve.
 > That's what prompted me to make a paper of it!

Going back to the original object isn't quite the same thing.
It's something of a red herring since this kind of thing is
extremely rarely used, but you can't claim full conformity
if you don't support it.

Here is what this kind of code looks like:

// Java
void f(I1 i1) { if (i1 instanceof I2) { I2 i2 = (I2)i1; } }

// C++
void f(I1 *i1) { I2 *i2 = dynamic_cast<I2 *>(i1); if (i2) { /*...*/ } }

As long as the underlying object has an accessible i2 in its
inheritance graph, the conversion works, and the code does not
need to know what the common ancestor class is, and will work
for many different ancestor types.

This is accomplished by compiler magic. The compiler has access
to the virtual tables and can search them for the presence of
appropriate bases.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-30 15:30       ` Hyman Rosen
@ 2002-07-30 17:34         ` Jim Rogers
  2002-07-30 18:20           ` Hyman Rosen
  2002-07-30 19:17           ` Robert A Duff
  0 siblings, 2 replies; 17+ messages in thread
From: Jim Rogers @ 2002-07-30 17:34 UTC (permalink / raw)


Hyman Rosen wrote:

> Jean-Pierre Rosen wrote:
> 
>> Yes. Or more exactly, the design pattern provides functions
> 
>  > that allow you to get an I1 or I2 view for a C object, and to
>  > go back from an I1 or I2 view back to the original C object.
> 
>>
>> And you are correct that this is not obvious to achieve.
> 
>  > That's what prompted me to make a paper of it!
> 
> Going back to the original object isn't quite the same thing.
> It's something of a red herring since this kind of thing is
> extremely rarely used, but you can't claim full conformity
> if you don't support it.
> 
> Here is what this kind of code looks like:
> 
> // Java
> void f(I1 i1) { if (i1 instanceof I2) { I2 i2 = (I2)i1; } }
> 
> // C++
> void f(I1 *i1) { I2 *i2 = dynamic_cast<I2 *>(i1); if (i2) { /*...*/ } }
> 
> As long as the underlying object has an accessible i2 in its
> inheritance graph, the conversion works, and the code does not
> need to know what the common ancestor class is, and will work
> for many different ancestor types.


In Java all classes have an ultimate shared ancestor, the Object
class.


> 
> This is accomplished by compiler magic. The compiler has access
> to the virtual tables and can search them for the presence of
> appropriate bases.
> 

I am not strong on C++ so I will deal with the Java example above.
All Java objects are accessed through references. This is equivalent
to having all Ada object accessed through access to class types.

The Ada equivalent for a tagged type is:

type I1_Access is access all I1'Class;
type I2_Access is access all I2'Class;

procedure f(item : in I1_Access)
    temp : I2_Access;
begin
    if item.all in I2'Class then
       temp := item;
    end if;
end f;

Note that this performs a lookup similar to what you describe.

Jim Rogers




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  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
  1 sibling, 1 reply; 17+ messages in thread
From: Hyman Rosen @ 2002-07-30 18:20 UTC (permalink / raw)


Jim Rogers wrote:
> In Java all classes have an ultimate shared ancestor, the Object
> class.

True, but not really relevant since Object is above (below?)
the interfaces. If I have
	Class C extends Object implements I1, I2
then if I know my I1 is a C then I know it's also
an I2, but knowing that my I1 is an Object doesn't
tell me anything.

> procedure f(item : in I1_Access)
>    if item.all in I2'Class then
> 
> Note that this performs a lookup similar to what you describe.

But it's much simpler in Ada, since there is neither multiple
inheritance nor interfaces. For the test to be potentially true,
either I1 must be a subclass of I2, in which case the test
succeeds immediately, or I2 is a subclass of I1, in which case
we must actually examine item to see whether it inherits from
an I2-derived class. If I1 and I2 are unrelated, the test will
always be false, which is not true for C++ or Java.

C++ (and maybe Java also) has additional issues because the base
class might not be accessible due to non-public inheritance, or
there may be more than one I2 in the inheritance graph.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-30 17:34         ` Jim Rogers
  2002-07-30 18:20           ` Hyman Rosen
@ 2002-07-30 19:17           ` Robert A Duff
  2002-07-30 22:10             ` Hyman Rosen
  1 sibling, 1 reply; 17+ messages in thread
From: Robert A Duff @ 2002-07-30 19:17 UTC (permalink / raw)


Jim Rogers <jimmaureenrogers@worldnet.att.net> writes:

> I am not strong on C++ so I will deal with the Java example above.
> All Java objects are accessed through references. This is equivalent
> to having all Ada object accessed through access to class types.

To mimic Java in this way, it seems that (in addition to what you said
above), you have to derive everything ultimately from one root type.
This happens automatically in Java, but in Ada it requires planning
ahead, which is impossible when combining two independently-developed
pieces of code.

> The Ada equivalent for a tagged type is:
> 
> type I1_Access is access all I1'Class;
> type I2_Access is access all I2'Class;
> 
> procedure f(item : in I1_Access)
>     temp : I2_Access;
> begin
>     if item.all in I2'Class then

But this is illegal, unless I1 and I2 are "related" to each other.

>        temp := item;

This needs to be "temp := I2_Access(item);", which is again illegal
in the same circumstance.

>     end if;
> end f;
> 
> Note that this performs a lookup similar to what you describe.

By the way, the ARG is working on a feature that mimics Java's
interfaces (i.e., multiple inheritance without the pain), but I
don't think it does what Hyman Rosen wanted.  (OK, he didn't say he
*wanted* it; he just said that C++ supports it.)

I would like to see an example of why it is wanted.  On the face of it,
it seems weird to reach off into the far distance and ask whether this
thing I have my hands on just *happens* to obey some totally unrelated
interface.

- Bob



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x  to satisfy a Java language advocate?
  2002-07-30 18:20           ` Hyman Rosen
@ 2002-07-30 20:22             ` Robert A Duff
  0 siblings, 0 replies; 17+ messages in thread
From: Robert A Duff @ 2002-07-30 20:22 UTC (permalink / raw)


Hyman Rosen <hyrosen@mail.com> writes:

> But it's much simpler in Ada, since there is neither multiple
> inheritance nor interfaces. For the test to be potentially true,
> either I1 must be a subclass of I2, in which case the test
> succeeds immediately, or I2 is a subclass of I1, in which case
> we must actually examine item to see whether it inherits from
> an I2-derived class. If I1 and I2 are unrelated, the test will
> always be false, which is not true for C++ or Java.
  ^^^^^^^^^^^^^^^

No, it's always illegal (i.e. compile-time error).

- Bob



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x   to satisfy a Java language advocate?
  2002-07-30  8:13   ` Dmitry A. Kazakov
@ 2002-07-30 20:55     ` Robert Dewar
  2002-07-31 22:08       ` Dmitry A.Kazakov
  0 siblings, 1 reply; 17+ messages in thread
From: Robert Dewar @ 2002-07-30 20:55 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<1cickuo7c6qhqnpgi5lhtg9tdt6m1nbpuc@4ax.com>...

> I believe the answer is yes, however Ada community is yet not ready to
> accept this fact.

Just possibly there is a difference between a fact and something that
Dmitry believes :-)



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
  2002-07-30 19:17           ` Robert A Duff
@ 2002-07-30 22:10             ` Hyman Rosen
  0 siblings, 0 replies; 17+ messages in thread
From: Hyman Rosen @ 2002-07-30 22:10 UTC (permalink / raw)


Robert A Duff wrote:
> I would like to see an example of why it is wanted.  On the face of it,
> it seems weird to reach off into the far distance and ask whether this
> thing I have my hands on just *happens* to obey some totally unrelated
> interface.

In C++, it's just a part of RTTI (run-time type inquiry).

I imagine it's used mostly in "interface discovery" contexts.
That is, you have a pointer to an interface, and you want to
know whether the underlying object supports other, possibly
related interfaces. So you do the cast, and if returns a
non-null value, you know the interface is supported. Both
COM and CORBA have very similar concepts.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x   to satisfy a Java language advocate?
  2002-07-30 20:55     ` Robert Dewar
@ 2002-07-31 22:08       ` Dmitry A.Kazakov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry A.Kazakov @ 2002-07-31 22:08 UTC (permalink / raw)


Robert Dewar wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message
> news:<1cickuo7c6qhqnpgi5lhtg9tdt6m1nbpuc@4ax.com>...
> 
>> I believe the answer is yes, however Ada community is yet not ready to
>> accept this fact.
> 
> Just possibly there is a difference between a fact and something that
> Dmitry believes :-)

Let's call it a fact of my belief (:-))

-- 
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2002-07-31 22:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-29 12:05 Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate? Colin Paul Gloster
2002-07-29 12:42 ` 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

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