comp.lang.ada
 help / color / mirror / Atom feed
From: lutz@iks-jena.de (Lutz Donnerhacke)
Subject: Re: Sugestion to Multiple Inheritance
Date: Mon, 21 Jan 2002 11:23:31 +0000 (UTC)
Date: 2002-01-21T11:23:31+00:00	[thread overview]
Message-ID: <slrna4nuhh.kn.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: u4gs37ftpseo27@corp.supernews.com

* Matthew Heaney wrote:
>"Lutz Donnerhacke" <lutz@iks-jena.de> 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.
    



  reply	other threads:[~2002-01-21 11:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-11 10:20 Sugestion to Multiple Inheritance Lutz Donnerhacke
2002-01-11 17:21 ` Stephen Leake
2002-01-11 17:53   ` Lutz Donnerhacke
2002-01-11 19:57     ` Stephen Leake
2002-01-17  8:28       ` Lutz Donnerhacke
2002-01-17 14:31         ` Stephen Leake
2002-01-17 14:54           ` Lutz Donnerhacke
2002-01-17 20:52             ` Jim Rogers
2002-01-11 18:07 ` Mark Lundquist
2002-01-11 18:14 ` Richard Riehle
2002-01-11 20:56   ` Hyman Rosen
2002-01-12  7:35     ` Richard Riehle
2002-01-13  6:37       ` Hyman Rosen
2002-01-14 13:58         ` John English
2002-01-14 16:27           ` Ole-Hjalmar Kristensen
2002-01-12  2:09   ` Will
2002-01-11 22:04 ` Matthew Heaney
2002-01-15 15:32   ` Hyman Rosen
2002-01-15 16:03     ` Lutz Donnerhacke
2002-01-18 19:03       ` Matthew Heaney
2002-01-21 11:23         ` Lutz Donnerhacke [this message]
2002-01-21 16:43           ` Brian Rogoff
2002-01-21 17:00             ` Lutz Donnerhacke
2002-01-22 16:55               ` Brian Rogoff
2002-01-23  8:58                 ` Dmitry A. Kazakov
2002-01-25  0:09                   ` Brian Rogoff
2002-01-28 16:23                     ` Dmitry A. Kazakov
2002-01-12  0:28 ` Nick Roberts
replies disabled

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