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=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7ee10ec601726fbf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 15:05:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Eric Merritt Newsgroups: comp.lang.ada Subject: Re: Questions - Polimorphism/Dynamic Binding Date: Tue, 30 Oct 2001 15:04:10 -0800 (PST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: avanie.enst.fr 1004483142 11517 137.194.161.2 (30 Oct 2001 23:05:42 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 30 Oct 2001 23:05:42 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: In-Reply-To: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:15442 Date: 2001-10-30T15:04:10-08:00 Matthew, > Not directly. For now the closest thing you can do > is use the "multiple > views" idiom. Suppose you have an "interface" type: > > package P is > > type T is tagged limited null record; > procedure Op (O : in out T) is abstract; > > end P; > > Now what we want is to have a tagged type that > "conforms" to this interface. > One way to do this is like this (I haven't tried > compiling this, but you'll > get the idea): > > with P; > package Q is > > type T_Public; > > type TI is new P.T (O : access T_Public) with > null record; > procedure Op (O : in out TI); > > type T_Public is abstract tagged limited record > I : aliased TI; > end record; > > type T is new T_Public with private; > procedure Op2 (O : in T); > ... > end Q; > > This idea is that if you have an object of type T, > then you can either view > it as a T, or use its (public) I component to view > it as the interface type > P.T: > > declare > O : Q.T; > begin > Op2 (O); --view as a Q.T > Op (O.I); --view as "interface" P.T > end; > > The interface part of T (its component I) can view > the outer type through > its access discriminant. Good explaination but, there is one aspect that is missing. One of the benifits of Java Interfaces is that it allows a form of quasi-multiple inheritance. What I mean is that it will still allow you to inherit from a root class and implement multiple interfaces. In this case and interface almose becomes a kind of agreement between the two bits of code the provider agreeing to provide certain methods. I think this is fairly easy to work around with a little forsight, there is allways the delegation pattern for multiple inheritance and that of course works in ada quite well. __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com