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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16b1ef91d331648c,start X-Google-Attributes: gid103376,public From: Anton Gibbs Subject: Barnes vs. Dewar Date: 1999/08/27 Message-ID: <37C66E08.16DB@dera.gov.uk>#1/1 X-Deja-AN: 517748012 Content-Transfer-Encoding: 7bit Organization: Eurocontrol Integration Team Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-27T00:00:00+00:00 List-Id: 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."