comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@home.com>
Subject: Re: Streams Quandry in Ada95
Date: Wed, 13 Dec 2000 20:04:06 GMT
Date: 2000-12-13T20:04:06+00:00	[thread overview]
Message-ID: <3A37D5BC.982E3BDF@home.com> (raw)
In-Reply-To: YwPZ5.25237$M5.917159@news1.frmt1.sfba.home.com

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 <serko84@hotmail.com> 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





  reply	other threads:[~2000-12-13 20:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3A370548.B8AF2579@home.com>
2000-12-13 16:27 ` Streams Quandry in Ada95 Stephen Leake
2000-12-13 17:39   ` Warren W. Gay VE3WWG
2000-12-13 18:49     ` tmoran
2000-12-13 20:04       ` Warren W. Gay VE3WWG [this message]
2000-12-14  2:35         ` Streams Quandry in Ada95 (SOLVED) Warren W. Gay VE3WWG
2000-12-14 12:08         ` Streams Quandry in Ada95 Robert Dewar
2000-12-14 14:19           ` Warren W. Gay VE3WWG
2000-12-14 21:43           ` Sergey Koshcheyev
2000-12-13 18:58     ` Anders Gidenstam
replies disabled

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