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,34c2aa33b8bdb1a9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-21 03:23:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Re: Sugestion to Multiple Inheritance Date: Mon, 21 Jan 2002 11:23:31 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <3C444B8D.70309@mail.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1011612211 1738 217.17.192.37 (21 Jan 2002 11:23:31 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Mon, 21 Jan 2002 11:23:31 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:19135 Date: 2002-01-21T11:23:31+00:00 List-Id: * Matthew Heaney wrote: >"Lutz Donnerhacke" wrote in message >> Exactly. Matthew showed also the impact of multiple inheritance by >> duplicating the multiple included structure A. I'm pretty sure to find >> a way without MI. Simply by designing the whole type more carefully and >> use derivated packages. > >It's not clear what you're trying to do here, using a type hierarchy. > >Do you want a generic algorithm, that works for any kind of collection? Yes. >If so, then what's wrong with the model that the C++ STL uses? It doesn't >use tagged types, just generics. Generics does not provide an abstract interface fullfilled by different implemenations. I.e. a list-collection may generate a forward_iterator. An algorithm requires forward_iterators aof any kind. The list-collection might be instantiated by an array of limited types or a single-linked-list. But every instatiation should provide the full interface of the iterator and collection abstraction. Sorry for beeing so vague, I'm still looking for a solution. >You can do something very similar in Ada95: > >generic > type Iterator_Type is private; > with function Is_Less (L, R : Iterator_Type) return Boolean is <>; > with procedure Swap (L, R : Iterator_Type) is <>; > with function "+" (L : Iterator_Type; R : Integer) > return Iterator_Type is <>; > with function "-" (L : Iterator_Type; R : Integer) > return Iterator_Type is <>; > with function "-" (L, R : Iterator_Type) > return Integer is <>; > with function "<" (L, R : Iterator_Type) > return Boolean is <>; > with function "=" (L, R : Iterator_Type) > return Boolean is <>; >procedure Generic_Quicksort > (First : in Iterator_Type; > Back : in Iterator_Type); > >This will work for any collection that has an iterator. It even works for >arrays. The algorithm itself doesn't know anything about the collection >type or the item type. Exactly. I thought about: generic type Iterator_Type is new Forward_Iterator with private; procedure Generic_XXX getting the necessary interface from an abstaction.