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,93dce172c8d3e2fb X-Google-Attributes: gid103376,public From: jsa@alexandria.organon.com (Jon S Anthony) Subject: Re: Which compiler is correct? Date: 1997/06/20 Message-ID: #1/1 X-Deja-AN: 251440449 Distribution: world References: <33A77C54.5484@bix.com> Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-06-20T00:00:00+00:00 List-Id: In article woodruff@tanana.llnl.gov (John Woodruff) writes: > Here is another inquiry of the type "which compiler is correct." It is > so similar to the issue Bob answered for Tom that I retain the thread > (and the answer Bob gave is so clear that I imagine that this one will > be equally easy to understand once I know the answer.) > > Let me define a package with a tagged private type: > package Parent is > type Obj is tagged private ; > private > type Obj is tagged record > I : Integer ; > end record ; > end Parent ; > > The package has just one child that extends the type. Depending on the > specifics of how I derive the new type, I get correct code or code that > evokes an error message that I don't understand: > > package Parent.Child is > type Good_Obj is new Parent.Obj with private ; > type Bad_Obj is new Parent.Obj with null record ; NOTE: at this point a) Parent's i component is _not_ visible and so not available to this view of the children. b) Bad_Obj is _fully_ declared at this point and so will never get the implicit declaration of Parent's i component. > procedure Do_Nothing ; -- just to require body > private > type Good_Obj is new Parent.Obj with null record ; At this point, Parent.I is visible and the full declaration of Good_Obj implicitly declares this component. > end ; > > One of the compilers (compiler "r") is able to compile the body without > error; the other compiler reports an error in the body when I try to > reference the component of the parent type. > > package body Parent.Child is > good : Good_Obj ; > Bad : Bad_Obj ; > procedure Do_Nothing is > begin > null; > end ; > begin > Good.I := 2 ; > Bad.I := 2 ; -- compiler "g" reports error > end ; So, Bad.I is not directly available and compiler "g", I believe, is correct. > selector". I am unable to think of a reason why the body of the child > package can reference the parent's private declaration of Obj for one, > but not for the other derived types. I think this all falls out of the rules in 7.3.1, and in particular pay close attention to what is said in (3). /Jon -- Jon Anthony OMI, Belmont, MA 02178 617.484.3383 "Nightmares - Ha! The way my life's been going lately, Who'd notice?" -- Londo Mollari