comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate?
Date: Tue, 30 Jul 2002 19:17:53 GMT
Date: 2002-07-30T19:17:53+00:00	[thread overview]
Message-ID: <wccbs8pgh3y.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 3D46CE25.5010102@worldnet.att.net

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



  parent reply	other threads:[~2002-07-30 19:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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