From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c5e219ab41be8c00 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-03 11:15:05 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!sjc-peer.news.verio.net!news.verio.net!sjc-read.news.verio.net.POSTED!not-for-mail Newsgroups: comp.lang.ada From: Brian Rogoff Subject: Re: Multiple Interface Inheritance (was Re: JGNAT and ObjectAdaand...) In-Reply-To: <3A5247CF.E694B80F@averstar.com> Message-ID: References: <3A3E8A9E.D12673A7@libertysurf.fr> <91nur2$ulk$1@nnrp1.deja.com> <3A3F8651.7CDB13B6@averstar.com> <3A410EC1.106C74CC@averstar.com> <3A413FBB.3E852649@averstar.com> <926vah$iu4$1@news.huji.ac.il> <3A5247CF.E694B80F@averstar.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Wed, 03 Jan 2001 19:15:24 GMT NNTP-Posting-Host: 206.184.139.136 X-Complaints-To: abuse@verio.net X-Trace: sjc-read.news.verio.net 978549324 206.184.139.136 (Wed, 03 Jan 2001 19:15:24 GMT) NNTP-Posting-Date: Wed, 03 Jan 2001 19:15:24 GMT Organization: Verio Xref: supernews.google.com comp.lang.ada:3618 Date: 2001-01-03T19:15:24+00:00 List-Id: 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