comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Multiple Interface Inheritance (was Re: JGNAT and ObjectAdaand...)
Date: Tue, 02 Jan 2001 16:27:43 -0500
Date: 2001-01-02T21:27:43+00:00	[thread overview]
Message-ID: <3A5247CF.E694B80F@averstar.com> (raw)
In-Reply-To: Pine.BSF.4.21.0012251022110.1095-100000@shell5.ba.best.com

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.

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?

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.

> 
> -- Brian

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Commercial Division, AverStar (formerly Intermetrics)
(http://www.averstar.com/services/IT_consulting.html)  Burlington, MA  USA



  parent reply	other threads:[~2001-01-02 21:27 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 [this message]
2001-01-03 19:15                     ` Brian Rogoff
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