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 12:04:11 PST Path: supernews.google.com!sn-xit-02!supernews.com!216.227.56.88.MISMATCH!telocity-west!TELOCITY!cyclone.bc.net!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3A37D5BC.982E3BDF@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Streams Quandry in Ada95 References: <3A37B3C3.86CFCF66@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 13 Dec 2000 20:04:06 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Wed, 13 Dec 2000 13:04:06 MDT Organization: MetroNet Communications Group Inc. Xref: supernews.google.com comp.lang.ada:3088 Date: 2000-12-13T20:04:06+00:00 List-Id: tmoran@acm.org wrote: > >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. Basically, I was already doing that, and agree that it should be done that way. I just got an email from Sergey Koshcheyev who I think has solved this riddle (to be confirmed tonight). He says: "it looks that the problem is you're using Audio_Stream as both the package name and the type name, so the compiler is getting confused..." I think he may be right. He continues "...after renaming the package to Audio_Stream_Package (Audio_Streams may be a better name) and uncommenting the Pump call and the corresponding 'with'es in main.adb, the code compiles fine,...". So my problems were probably due to the compiler getting confused in different contexts about what I was trying to do. I'll try to confirm this tonight myself, and report back to the group. Thanks! > 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? I'll have to check, but type Audio_Stream was already a class-wide type, but yes, that is the idea. However, as previously mentioned, I believe my woes are due to naming conflicts that Sergey Koshcheyev wrote to me about. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg