comp.lang.ada
 help / color / mirror / Atom feed
From: Anton Gibbs <agibbs@dera.gov.uk>
Subject: Barnes vs. Dewar
Date: 1999/08/27
Date: 1999-08-27T00:00:00+00:00	[thread overview]
Message-ID: <37C66E08.16DB@dera.gov.uk> (raw)

Dear Ada Experts,

     Here is an interesting one based on Chapter 13.7 (Controlled Types)
from John Barnes' book Programming in Ada 95.

Although the subject under discussion is controlled types, the author
takes the opportunity to illustrate the use of type extension as a means
of limiting the user view of a type. The relevant code fragment is:-

package Tracked_Things is

   type Identity_Controlled is abstract tagged private;

private

   type Identity_Controlled is abstract new Controlled with
   record
      Identity_Number : Integer;
   end record;

   procedure Initialize( X : in Identity_Controlled );
   -- etc.

end Tracked_Things;

package Tracked_Things.User_View is
 
   type Thing is new Identity_Controlled with
   record
      UU : Integer;
   end record;

end Tracked_Things.User_View;

[There are few with/use clauses implied here].


Page 287, third paragraph from the end, last sentance reads:

   "We also declare Initialize, Adjust and Finalize in the private part
and so they are also hidden from the user."

Clearly, these operations are expected to be inherited for the extended
type `Thing' in child package `Tracked_Things.User_View'.

Well, when I tried a similar thing with the GNAT compiler it threw it
out complaining that:

   "Initialize" is not a visible entity of "User_View"

After the usual agony with the LRM, I eventually had to agree. I do not
think that the child package `Tracked_Things.User_View' is entitled to
see `Initialize' in the private part of its parent and so it cannot be
inherited. If you move `Initialize' to the visible part it all works
fine.

So who is right Barnes or Dewar ?

More to the point, what is the correct way to achieve the desired level
of visibility (ie. `Tracked_Things.User_View.Initialize' visible
but `Tracked_Things.Initialize' not) ?

Thanks for any clues.

Best -- Anton.

--
Anton Gibbs
Software Engineer
Civil Air Traffic Management Group
Defence Evaluation and Research Agency
Bedford, UK

"The Information contained in this E-Mail and any 
subsequent correspondence is private and is intended
solely for the intended recipient(s).  For those
other than the intended recipient any disclosure,
copying, distribution, or any action taken or 
omitted to be taken in reliance on such information
is prohibited and may be unlawful."




             reply	other threads:[~1999-08-27  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-27  0:00 Anton Gibbs [this message]
1999-08-27  0:00 ` Barnes vs. Dewar Robert A Duff
1999-08-27  0:00   ` Matthew Heaney
1999-08-30  0:00     ` Robert A Duff
1999-08-27  0:00 ` Matthew Heaney
1999-08-29  0:00 ` Robert Dewar
replies disabled

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