From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: OO in Ada
Date: Tue, 8 Oct 2002 13:58:56 -0400
Date: 2002-10-08T13:58:56-04:00 [thread overview]
Message-ID: <uq6771747k3ke3@corp.supernews.com> (raw)
In-Reply-To: 3DA31301.80506@cogeco.ca
"Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> wrote in message
news:3DA31301.80506@cogeco.ca...
>
> I believe that the problem referred to here is simply one
> of a visibility. Either a 'use' or a fully qualified call is
> required.
No. Primitive operations for a type are inherited during a derivation (it
doesn't matter what kind of type the parent is), and are therefore
"implicitly declared" immediately following the declaration of the derived
type.
For example:
package P is
type T is range 0 .. 10;
procedure Op (O : in T);
end:
with P;
package Q is
type NT is new P.T;
end;
There is an operation called Op implicitly declared for Q.NT. To call it
you do NOT have to with P. For example:
declare
use Q;
O : NT;
begin
Op (O);
end;
Op does NOT need any qualification, because it's already declared in Q, and
the operations in Q (even implicitly declared operations) are directly
visible (here, because use Q).
> If I understand correctly, you're saying you have
> some parent package "Pen", and a child package "Thick_Pen",
> and you use the package as in:
>
> use Pen.Thick_Pen;
> ...
> Draw(...); -- Compile error because Draw is defined in Pen
The Draw operation that takes a thick pen type is (implicitly) declared in
package Thick_Pen. There is NO compile error. It doesn't even matter
whether package Think_Pen is a child of Pen.
Primitive operations of a type are inherited during a derivation. That's
what it means for an operation to be "primitive."
> This is solved either by doing something like:
>
> use Pen, Pen.Thick_Pen;
> ...
> Draw(...); -- OK now, because Pen.Draw is visible.
This will NOT compile, because Pen.Draw takes Pen_Type, not Thick_Pen_Type.
> or qualifying by your call as in:
>
> use Pen.Thick_Pen;
> ...
> Pen.Draw(...);
No. This won't compile either. You need to say:
Pen.Thick_Pen.Draw(...);
next prev parent reply other threads:[~2002-10-08 17:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-04 2:14 OO in Ada Rick Duley
2002-10-04 2:55 ` Jim Rogers
2002-10-04 17:35 ` Hyman Rosen
2002-10-05 0:20 ` Jim Rogers
2002-10-05 23:38 ` Dmitry A.Kazakov
2002-10-05 15:25 ` Jim Rogers
2002-10-06 21:37 ` Dmitry A.Kazakov
2002-10-06 2:18 ` Hyman Rosen
2002-10-06 3:00 ` Jim Rogers
2002-10-08 21:08 ` Gisle Sælensminde
2002-10-04 3:37 ` Chad R. Meiners
2002-10-04 5:32 ` Simon Wright
2002-10-04 6:01 ` tmoran
2002-10-04 15:05 ` Matthew Heaney
2002-10-05 2:14 ` SteveD
2002-10-05 8:54 ` Preben Randhol
2002-10-07 14:10 ` Matthew Heaney
2002-10-07 19:52 ` Jeffrey Carter
2002-10-08 21:18 ` Dmitry A.Kazakov
2002-10-08 9:53 ` John McCabe
2002-10-08 15:37 ` Matthew Heaney
2002-10-08 16:47 ` Georg Bauhaus
2002-10-08 17:48 ` Matthew Heaney
2002-10-08 17:16 ` Warren W. Gay VE3WWG
2002-10-08 17:58 ` Matthew Heaney [this message]
2002-10-09 16:59 ` Warren W. Gay VE3WWG
2002-10-08 10:21 ` Preben Randhol
-- strict thread matches above, loose matches on Subject: below --
1998-05-15 0:00 Gisle S{lensminde
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox