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,FREEMAIL_FROM, T_FILL_THIS_FORM_SHORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!n21g2000vba.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.ada Subject: Indirect visibility of private part in child packages Date: Wed, 3 Jun 2009 22:45:43 -0700 (PDT) Organization: http://groups.google.com Message-ID: <77683561-2b21-42c3-8c90-6c08a0c16b99@n21g2000vba.googlegroups.com> NNTP-Posting-Host: 86.75.149.31 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1244094344 18818 127.0.0.1 (4 Jun 2009 05:45:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 Jun 2009 05:45:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n21g2000vba.googlegroups.com; posting-host=86.75.149.31; posting-account=vrfdLAoAAAAauX_3XwyXEwXCWN3A1l8D User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; fr),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6201 Date: 2009-06-03T22:45:43-07:00 List-Id: Hi all, I've meet a tortuous question with a set of packages I'm converting from Pascal (as I use Ada now, I'm taking the opportunity to re-create a nicer design). The question I'm facing deals with visibility of private part in child package. More precisely, an indirect visibility of a private part. An exemple will better show the case: This can be reduced to three package (specs and bodies) The root package: >>>>> -------------------------------------------------- package P1 is type T1_Type is tagged private; -- Some primitives on T1_Type are specified here ... private type T1_Type is tagged record Low_Level_Data : Some_Type; end record; -- T1_Type end P1; <<<<< -------------------------------------------------- The first child package (with this one, every thing's Ok): >>>>> -------------------------------------------------- package P1.P2 is type T2_Type is new T1_Type with private; -- Some primitives on T2_Type are specified here ... procedure A_Primitive (Item : out T2_Type); private type T2_Type is new T1_Type with null record; end P1.P2; package body P1.P2 is procedure A_Primitive (Item : out T2_Type) is begin Item.Low_Level_Data := ...; -- It works, beceause P1.P2 is a child -- package with a view on P1's private part end A_Primitive; end P1.P2; <<<<< -------------------------------------------------- The second child package (the one which turns into a subtile doubt): >>>>> -------------------------------------------------- with P1.P2; package P1.P3 is type T3_Type is new P1.P2.T2_Type with private; -- Some primitives on T2_Type are specified here ... procedure A_Primitive (Item : out T3_Type); private type T3_Type is new P1.P2.T2_Type with null record; end P1.P3; package body P1.P3 is procedure A_Primitive (Item : out T3_Type) is begin Item.Low_Level_Data := ...; -- It fails : the compiler complains there is no -- selector "Low_Level_Data" defined for T3_Type end A_Primitive; end P1.P3; <<<<< -------------------------------------------------- As said in the last comment, it seems P1.P3 cannot see the T1_Type.Low_Level_Data member. But as P3 is a child package of P1, it has a view on P1's private part, and there is indeed no trouble about it with P2. P3 know P2.T2_Type is derived from P1.T1_Type, and P3 has a view on T1_Type privates. But it seems the compiler does not care about it. There may be interpretation matter here : does the private specification, means "disallow access to private part" or does it means "do not provide an access to the private part". If it means "disallow access to private part", then it ill explain why P3 cannot access T1_Type.Low_Level_Data member. But if it means "do no provide an access to private" part, then P3 should still be able to access T1.Low_Level_Data, beceause it has an access to this as a child package of P1. What does long experienced lawyers think about it ? I've try to look in section 8 of the "RM 2005", but either the answer was not there or else, I missed it. Note #1: I hope my exemple is clear enought. If it is not, please, tell me, so that I can attempt to reword it. Note #2: I do not want to make P3 a child package of P2, beceause it does not need to access any internals of T2_Type. I want to have some types, extending each others, and doing so only relying on either public interface or on the sole common private part defined in P1.