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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!h11g2000yqb.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Hibou57_=28Yannick_Duch=EAne=29?= Newsgroups: comp.lang.ada Subject: Re: Indirect visibility of private part in child packages Date: Thu, 4 Jun 2009 04:47:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <77683561-2b21-42c3-8c90-6c08a0c16b99@n21g2000vba.googlegroups.com> <5854cebc-55a9-469d-88bd-86b4704f8689@c19g2000yqc.googlegroups.com> NNTP-Posting-Host: 77.198.58.250 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1244116046 22215 127.0.0.1 (4 Jun 2009 11:47:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 Jun 2009 11:47:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h11g2000yqb.googlegroups.com; posting-host=77.198.58.250; 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:6228 Date: 2009-06-04T04:47:26-07:00 List-Id: Bonjour Ludovic, and thanks for your reply :) On 4 juin, 09:50, Ludovic Brenta wrote: > Maybe you can solve your problem like this: > > package body P1.P3 is > =A0 =A0procedure A_Primitive (Item : out T3_Type) is > =A0 =A0begin > =A0 =A0 =A0 T1_Type (Item).Low_Level_Data :=3D ...; > =A0 =A0end A_Primitive; > end P1.P3; I've just tried it, and it does not work better. The compiler complains there are not selector Low_Level_Data for T1_Type. > I am undecided whether the compiler is correct or wrong about the > visibility of Low_Level_Data. On the one hand, P1.P3 cannot see the > full declaration of T2_Type; on the other hand, it can see that > T2_Type publicly inherits from T1_Type and can also see the full > declaration of T1_Type. This is exactly the same think in my mind. Perhaps the semantic is ambigous here. > It seems that the public (partial) view of T2_Type hides the full > declaration of T1_Type. So, I think my solution would work by removing > T2_Type out of the way. T2_Type is required ;) The purpose is to have T2_Type and T3_Type, and may be later some others, beside of each other. > Another solution, which enforces encapsulation better, would be: > > package P1 is > =A0 =A0type T1_Type is tagged private; > private > =A0 =A0type Some_Type is ...; > =A0 =A0type T1_Type is tagged record > =A0 =A0 =A0Low_Level_Data : Some_Type; > =A0 =A0end record; > =A0 =A0procedure Set (Item : out T1_Type; Data : in Some_Type); > end P1; > > package body P1.P3 is > =A0 =A0procedure A_Primitive (Item : out T3_Type) is > =A0 =A0begin > =A0 =A0 =A0 Set (Item, Data =3D> ...); -- OK, calls inherited primitive > operation > =A0 =A0end A_Primitive; > end P1.P3; > > HTH I will try it soon and tell about the result. But at first sight, I think that the compiler gonna complain that Set is a primitive of T1_Type and thus that it must be defined in the public part. Further more, I think Set would habe to be redefined for each T2_Type, T3_Type and etc. Will try and tell later Have a nice day