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 09:39:14 PST Path: supernews.google.com!sn-xit-02!supernews.com!newsfeed.mesh.ad.jp!cyclone.bc.net!newsfeed.direct.ca!look.ca!news1.tor.metronet.ca!nnrp1.tor.metronet.ca!not-for-mail Message-ID: <3A37B3C3.86CFCF66@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: <3A370548.B8AF2579@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 13 Dec 2000 17:39:13 GMT NNTP-Posting-Host: 198.96.47.195 NNTP-Posting-Date: Wed, 13 Dec 2000 10:39:13 MDT Organization: MetroNet Communications Group Inc. Xref: supernews.google.com comp.lang.ada:3077 Date: 2000-12-13T17:39:13+00:00 List-Id: Stephen Leake wrote: > "Warren W. Gay VE3WWG" writes: > > > SHORT PROBLEM DESCRIPTION: > > > > The "Ada95" problem surrounds limited types, > > stream types and abstraction of types/primitives. > > > > You don't say exactly what the issue is; the code compiles (almost) > cleanly, and appears to implement your objective. What do you want to > change? What doesn't work? The problems are many. In its present form (after uncommenting the with clause for codec, and the pump call), gives you: gnatmake -gnatf main gnatgcc -c -gnatf main.adb codec.ads:9:37: subtype mark required in this context gnatmake: "main.adb" compilation error If you look at codec.ads you'll see that it expects Audio_Stream. You cannot convert the streams to Audio_Stream, as attempted below: Pump(Audio_Stream(Au_Str),Audio_Stream(DSP_Str)); This gives you: gnatgcc -c -gnatf main.adb main.adb:22:10: incorrect use of "Audio_Stream" main.adb:22:31: incorrect use of "Audio_Stream" codec.ads:9:37: subtype mark required in this context gnatmake: "main.adb" compilation error IGNORING that for a moment however, the REAL issue is this: The problem is that the codec routine Pump() cannot work with its arguments, because they are from an abstract stream (Audio_Stream). However, I cannot make them concrete, unless I choose BEFOREHAND, what streams I want to use (in this case I would be forced to choose Au_Stream and/or DSP_Stream, which are derived from Audio_Stream). But I want to accept _ANY_ Audio_Stream _DERIVED_ stream. So the question is, do I really have to define a derived stream with no-op primitives to avoid the "abstract" taint? i.e. Au_stream <= no-op <= Audio_Stream(*) <= ... <= Root_Stream_Type(*) DSP_Stream <= no-op <= Audio_Stream(*) <= ... <= Root_Stream_Type(*) where (*) is abstract. I would think that the whole point of abstraction is to force derived objects to provide those primitives. However, I cannot USE the abstract object itself (which makes sense-- what I really want to say is I want arguments that represent any stream derived from the abstract Audio_Stream type). 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). So how do I write a procedure that says: procedure Pump(In_Str, Out_Str: Any_Stream_Derived_From Audio_Stream); without losing the benefits of what abstract primitives force upon the derived stream? I've exhausted all reasonable approaches I can think of here, apart from the No-op derived stream. -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg