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,ASCII-7-bit X-Google-Thread: 103376,3a34550290fdc12c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-11 04:56:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!snoopy.risq.qc.ca!newsfeed.news2me.com!elnk-pas-nf2!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: Marin David Condic Newsgroups: comp.lang.ada Subject: Re: Problems with tagged records and inheritance Date: Fri, 11 Jul 2003 07:56:07 -0400 Organization: MindSpring Enterprises Message-ID: <3F0EA5D7.9020207@noplace.com> References: NNTP-Posting-Host: d1.56.b3.d1 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Server-Date: 11 Jul 2003 11:56:13 GMT User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 (OEM-HPQ-PRS1C03) X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:40188 Date: 2003-07-11T11:56:13+00:00 List-Id: That looks like a really helpful answer for an Ada newbie. It illustrates how to fix the problem very well. Just in case the OP had reasons to want visibility of AAA, we should point out that the way to create a child package looks something like this: package Base_Class is ... type Base is tagged private; ... type Base is tagged record AAA: Integer:=1; end record; end Base_Class ; ... package Base_Class.Child_Class is type Child is new Base with private; .... type Child is new Base with record BBB: Integer:=5; end record; end Base_Class.Child_Class ; Now the child package would have full knowledge of what is inside the private part of the Base_Class package and could reference the AAA field. Note that there are reasons you may not want to do that. Gaining visibility to the private part of the package pretty much violates the whole concept of why it was made private in the first place. Generally, providing accessor functions for the fields of interest or procedures for other operations on the hidden information is a better choice. I generally like to go to a child package with full visibility of the private section in cases where I am conveniently sectioning off operations for a class. The parent may have basic accessor & construction/destruction operations. One child may provide operations for I/O to/from files, another might provide display capabilities, etc. Where I do type extension is when I am providing a family of classes to the user so they can pick the best one for the job. There is a little bit of an art to deciding when something should be a child package and when it should not, but you develop a sense for it with some experience building larger systems in Ada. MDC Ludovic Brenta wrote: > > I don't have all the details of your program, but I suspect that: > -- ====================================================================== Marin David Condic I work for: http://www.belcan.com/ My project is: http://www.jast.mil/ Send Replies To: m c o n d i c @ a c m . o r g "In general the art of government consists in taking as much money as possible from one class of citizens to give to the other." -- Voltaire ======================================================================