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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,CP1252 X-Google-Thread: 103376,3a34550290fdc12c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-10 15:24:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F0DE779.7070204@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problems with tagged records and inheritance References: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 24.62.164.137 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc52.ops.asp.att.net 1057875867 24.62.164.137 (Thu, 10 Jul 2003 22:24:27 GMT) NNTP-Posting-Date: Thu, 10 Jul 2003 22:24:27 GMT Organization: Comcast Online Date: Thu, 10 Jul 2003 22:24:27 GMT Xref: archiver1.google.com comp.lang.ada:40176 Date: 2003-07-10T22:24:27+00:00 List-Id: Papastefanos Serafeim wrote: > I have using a base type like this: > ... > type Base is tagged private; > ... -- Foot, bullet, shoot. > type Base is tagged record > AAA: Integer:=1; > end record; > > and a child type like this > > type Child is new Base with private; > .... > type Child is new Base with record > BBB: Integer:=5; > end record; > > The problem is that the following is not working: > > procedure Test(Ch: in Child) is > begin > Put(Ch.AAA); --<- This line has an error, it says no selector AAA for > type Child > Put(Ch.BBB); > end Test; > The procedure Test is declared in the same package > as the type Child and defined at the package's Body. Why would you expect this to work? You explicitly limited the knowledge of AAA to within the package where Base is declared, and in its childred. You can "fix" the problem by adding an inquiry function to the package containing Base: Put(Contents(Base(Ch))); (You need a view conversion to call it.) Or you can fix it by making the package that declares Child a child package of the one that contains Base. Or you can just make AAA public. I don't know what the "right" fix is because I have no idea what you are trying to do. But information hiding in Ada is not partial. There are some interesting issues that come up with three levels of derivation, and even with two levels you could have Child with two components named AAA, but never visible in the same contexts... > The error is becouse AAA is not part of Child. > Why is that ? I thought that Child would contain > AAA and BBB, and not only BBB... It contains both. The issue is where each is visible. As I pointed out, both could be named AAA (not a change you want to make). Since either AAA or BBB is visible but not both, there would be no problem if they had the same name. -- Robert I. Eachus �In an ally, considerations of house, clan, planet, race are insignificant beside two prime questions, which are: 1. Can he shoot? 2. Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and Steve Miller.