From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Which compiler is correct?
Date: 1997/06/21
Date: 1997-06-21T00:00:00+00:00 [thread overview]
Message-ID: <EC3t3q.BzJ@world.std.com> (raw)
In-Reply-To: JSA.97Jun20185414@alexandria.organon.com
In article <JSA.97Jun20185414@alexandria.organon.com>,
Jon S Anthony <jsa@alexandria.organon.com> wrote:
>In article <ud205z1ifw.fsf@tanana.llnl.gov> woodruff@tanana.llnl.gov (John Woodruff) writes:
...
>> 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.
Right.
>b) Bad_Obj is _fully_ declared at this point and so will never get the
>implicit declaration of Parent's i component.
No, that's not quite right.
>> procedure Do_Nothing ; -- just to require body
By the way, "pragma Elaborate_Body;" is a good way to require a body,
when it's not otherwise required.
>> private
At *this* point, an "additional characteristic" (see 7.3.1(3-4)) of
Parent.Obj (namely, the existence of I) becomes visible, and since this
is within the immediate scope of Bad_Obj, it gets an I, too. By magic.
Note: There's an AI that says this happens only *immediately* within the
immediate scope of Bad_Obj, to match Ada 83. (The wording of RM95
accidentally lets it happen *anywhere* within the immediate scope of
Bad_Obj, which is wrong.) That's irrelevant to this example.
>> 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.
No.
>> 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).
Closer attention than that. ;-)
- Bob
next prev parent reply other threads:[~1997-06-21 0:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-17 0:00 Which compiler is correct? Tom Moran
1997-06-18 0:00 ` Pascal Obry
1997-06-18 0:00 ` Tom Moran
1997-06-18 0:00 ` Robert A Duff
1997-06-18 0:00 ` John Woodruff
1997-06-19 0:00 ` Robert A Duff
1997-06-20 0:00 ` Jon S Anthony
1997-06-21 0:00 ` Robert A Duff [this message]
1997-06-26 0:00 ` Jon S Anthony
1997-06-19 0:00 ` Simon Wright
1997-06-20 0:00 ` Jon S Anthony
1997-06-21 0:00 ` Robert A Duff
1997-06-21 0:00 ` Robert A Duff
1997-06-21 0:00 ` Simon Wright
1997-06-23 0:00 ` Mats.Weber
1997-06-24 0:00 ` Jon S Anthony
-- strict thread matches above, loose matches on Subject: below --
1996-09-10 0:00 Which compiler is correct?? Robert B. Love
1996-09-10 0:00 ` Robert Dewar
1996-09-11 0:00 ` Robert B. Love
1996-09-10 0:00 ` Robert Dewar
1996-09-11 0:00 ` Robert A Duff
1996-09-12 0:00 ` Ken Cowan
1996-09-12 0:00 ` Ken Cowan
1996-09-13 0:00 ` Jon S Anthony
1996-09-11 0:00 ` Jon S Anthony
1996-09-12 0:00 ` Tucker Taft
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox