comp.lang.ada
 help / color / mirror / Atom feed
* Question about generic formal derived types
@ 1999-03-30  0:00 adam
  1999-03-30  0:00 ` Steve Quinlan
  1999-03-30  0:00 ` Stephen Leake
  0 siblings, 2 replies; 6+ messages in thread
From: adam @ 1999-03-30  0:00 UTC (permalink / raw)


In this program fragment:

-------------------------------------------------------------------------------
package Pack1 is
    type Root_Type is tagged record
        Field1 : Integer;
        Field2 : Boolean;
    end record;
end Pack1;

with Pack1;
generic
    type Formal_Type is new Pack1.Root_Type with private;
package Pack2 is
    type New_Type is new Formal_Type with record
        Field3 : Character;
    end record;
end Pack2;

with Pack1;
package Pack3 is
    type Root_Type_Extension is new Pack1.Root_Type with record
        Field3 : Float;
    end record;
end Pack3;

. . .

with Pack2;
with Pack3;
package body Pack4 is

    package Instantiation is new Pack2 (Pack3.Root_Type_Extension);

    procedure Inner is
        X : Character;
        Y : Instantiation.New_Type;
    begin
        X := Y.Field3;
    end Inner;

end Pack4;

-------------------------------------------------------------------------------

I can't believe that a record type can have two components of the same name,
but it appears that Instantiation.New_Type would have two components named
Field3.

When Y.Field3 is accessed, which Field3 is meant?

Which language rules in the RM govern this situation?

				-- thanks, Adam

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-03-31  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-30  0:00 Question about generic formal derived types adam
1999-03-30  0:00 ` Steve Quinlan
1999-03-30  0:00 ` Stephen Leake
1999-03-30  0:00   ` adam
1999-03-31  0:00     ` Stephen Leake
1999-03-31  0:00   ` robert_dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox