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 08:43:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed.news.qwest.net!dfw-peer.news.verio.net!news.verio.net!sea-read.news.verio.net.POSTED!not-for-mail Newsgroups: comp.lang.ada From: Brian Rogoff Subject: Re: Sugestion to Multiple Inheritance In-Reply-To: Message-ID: References: <3C444B8D.70309@mail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Mon, 21 Jan 2002 16:43:36 GMT NNTP-Posting-Host: 192.220.65.223 X-Complaints-To: abuse@verio.net X-Trace: sea-read.news.verio.net 1011631416 192.220.65.223 (Mon, 21 Jan 2002 16:43:36 GMT) NNTP-Posting-Date: Mon, 21 Jan 2002 16:43:36 GMT Organization: Verio Xref: archiver1.google.com comp.lang.ada:19144 Date: 2002-01-21T16:43:36+00:00 List-Id: On Mon, 21 Jan 2002, Lutz Donnerhacke wrote: > * Matthew Heaney wrote: > Generics does not provide an abstract interface fullfilled by different > implemenations. Yes, generics can do exactly that. Do you understand the signature idiom in Ada 95? What you don't get, that tagged types give you, is the same kind of polymorphism at run time. You pay for that run time capability with run time dispatch and the overhead of tagging. > An algorithm requires forward_iterators aof any kind. So you parameterize over a forward iterator signature, which looks something like this generic type Value_Type (<>) is limited private; type Pointer_Type is access Value_Type; type Iterator_Type is private; with procedure Incr (Iterator : in out Iterator_Type) is <>; with function Succ (Iterator : in Iterator_Type) return Iterator_Type is <>; with function Get_Value (Iterator : Iterator_Type) return Value_Type is <>; with procedure Set_Value (Iterator : in out Iterator_Type; Value : in Value_Type) is <>; with function Get_Pointer (Iterator : Iterator_Type) return Pointer_Type is <>; with function "=" (X, Y : Iterator_Type) return Boolean is <>; package Forward_Iterator_Signature is -- Look, no body! This is a signature package. end Forward_Iterator_Signature; and your algorithms package will look something like this with Forward_Iterator_Signature; generic with package Iterators is new Forward_Iterator_Signature(<>); use Iterators; package Forward_Algorithms is -- Nonmutating sequence algorithms generic with function "=" ( X, Y: in Value_Type ) return Boolean; function Find ( Start, Finish: in Iterator_Type; Value: in Value_Type ) return Iterator_Type; generic with function "=" ( X, Y: in Value_Type ) return Boolean; function Adjacent_Find ( Start, Finish: in Iterator_Type ) return Iterator_Type; -- ... etc., etc. end Forward_Algorithms; -- Brian