comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Multiple Interface Inheritance (was Re: JGNAT and ObjectAdaand...)
Date: Wed, 03 Jan 2001 19:15:24 GMT
Date: 2001-01-03T19:15:24+00:00	[thread overview]
Message-ID: <Pine.BSF.4.21.0101031101530.12612-100000@shell5.ba.best.com> (raw)
In-Reply-To: <3A5247CF.E694B80F@averstar.com>

On Tue, 2 Jan 2001, Tucker Taft wrote:
> Brian Rogoff wrote:
> > ... I still suggested an explict 'Interface or sigof rather
> > than suggesting inference, which is more powerful yet. All I want to know
> > is whether the ability to an extract an (anonymous?) interface from an
> > existing tagged type might reasonably be added to the proposal.
> 
> There is interest in being able to "extract" or "construct" an
> interface given an existing type.  One of the nice features of
> Ada generics is that you can instantiate a generic with a type
> and a set of operations that need not be primitives of the
> type.  The operations can be created locally to match the needs
> of the generic.  For example, you could define a "<" to be
> used by a sorting generic which determined the kind of ordering
> desired, but which had nothing to do with the "primitive" < of
> the type.  In my view, the generics of Eiffel are  somewhat less powerful
> because they don't really support this kind of "morphing" or
> after-the-fact generalization.

Yes, well said. 

> The interesting question for Ada is whether given the addition
> of an "abstract interface" capability, could one easily write
> a generic that essentially added an interface after-the-fact,
> and also did the "morphing."
> 
> For example, given the interface Ordered:
> 
>     type Ordered is abstract;
>     function "<"(Left, Right : Ordered) return Boolean is abstract;
> 
> one could write a generic as follows:
> 
>     generic
>         type T is tagged private;
>         with function "<"(Left, Right : T) return Boolean is <>;
>     package Ordered_Wrapper is
>         type Ordered_T is new T and Ordered with null record;
>         function "<"(Left, Right : Ordered_T) return Boolean;
>     end Ordered_Wrapper;
> 
>     package body Ordered_Wrapper is
>         function "<"(Left, Right : Ordered_T) return Boolean is
>         begin
>             return T(Left) < T(Right);
>         end "<";
>     end Ordered_Wrapper;
> 
> Does this solve at least part of the problem you were trying to solve?

I was tempted to write "no" initially since I think of generics as being a 
"static" compile-time mechanism (yeah I know that's not *really* true) and 
tagged types/abstract interfaces as being a run-time mechanism. However, 
this example does solve my practical problems. Very nice! I guess you now
have one more example to add to the proposal. I'll try and think of some 
more places where an explicit interface_of kind of construct might be
useful but I suspect that at least for my needs we're at the point of 
diminishing returns. 

So, when can we expect implementations? :-)

> In any case, feel free to propose something more specific.  Although
> I failed to do this in AI 251, providing clear and convincing examples of use
> is important to help understand the motivation behind the proposal.

I think just rewriting Java and (old) GNU C++ examples into "Ada251" should
provide sufficient motivation. The old signature papers for C++ had lots
of practical examples of where the feature was useful. It is clear that
there is customer demand, too. 

-- Brian





  reply	other threads:[~2001-01-03 19:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-18 22:07 JGNAT and ObjectAda and Thierry&Annick
2000-12-19 12:39 ` Colin Paul Gloster
2000-12-19 15:28 ` Robert Dewar
2000-12-19 16:01   ` Tucker Taft
2000-12-20 16:14     ` Brian Rogoff
2000-12-20 19:55       ` Multiple Interface Inheritance (was Re: JGNAT and ObjectAda and ...) Tucker Taft
2000-12-20 21:35         ` Brian Rogoff
2000-12-20 23:24           ` Multiple Interface Inheritance (was Re: JGNAT and ObjectAda and...) Tucker Taft
2000-12-21  5:34             ` Brian Rogoff
2000-12-24 20:48             ` Brian Rogoff
2000-12-25  8:06               ` Multiple Interface Inheritance (was Re: JGNAT and ObjectAdaand...) Ehud Lamm
2000-12-25 18:54                 ` Brian Rogoff
2000-12-26  7:18                   ` Ehud Lamm
2001-01-02 21:27                   ` Tucker Taft
2001-01-03 19:15                     ` Brian Rogoff [this message]
2000-12-20 20:34       ` JGNAT and ObjectAda and Robert Dewar
2000-12-20 21:24         ` Brian Rogoff
replies disabled

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