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,b57f84f15b8a93fb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-13 10:49:29 PST Path: supernews.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.frmt1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Streams Quandry in Ada95 References: <3A37B3C3.86CFCF66@home.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Wed, 13 Dec 2000 18:49:28 GMT NNTP-Posting-Host: 24.20.190.201 X-Complaints-To: abuse@home.net X-Trace: news1.frmt1.sfba.home.com 976733368 24.20.190.201 (Wed, 13 Dec 2000 10:49:28 PST) NNTP-Posting-Date: Wed, 13 Dec 2000 10:49:28 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: supernews.google.com comp.lang.ada:3083 Date: 2000-12-13T18:49:28+00:00 List-Id: >So how do I write a procedure that says: > >procedure Pump(In_Str, Out_Str: Any_Stream_Derived_From Audio_Stream); procedure Pump(In_Str, Out_Str: in out Audio_Stream'Class); >I can avoid the abstract problem by deriving from Audio_Stream and providing >no-op primitives for the abstract primitives. But if other streams derive from this, >they may forget to override those no-op primitives (though I could cheat and >raise exceptions... leading to run-time checks). Forget the no-ops, just make the primitives of the abstract Audio_Stream themselves abstract. Then anybody deriving a new non-abstract kind of Audio_Stream will be *required by the compiler* to supply overrides for the abstract primitives. Thus type Raw_Sample_Type is range 0 .. 127; -- or whatever type Audio_Stream is abstract tagged null record; function Get(Data : Audio_Stream) return Raw_Sample_Type is abstract; procedure Put(Sample : in Raw_Sample_Type; Data : in out Audio_Stream) is abstract; procedure Pump(In_Str, Out_Str: in out Audio_Stream'Class); ... procedure Pump(In_Str, Out_Str: in out Audio_Stream'Class) is Sample : Raw_Sample_Type; begin loop Sample := Get(In_Str); Put(Sample, Out_Str); end loop; end Pump; Is this the sort of thing you want to do?