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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2813882933f323d0 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Recursive tagged types Date: 1997/11/10 Message-ID: <34675FB1.7C8@gsfc.nasa.gov>#1/1 X-Deja-AN: 288369482 References: <878950835.1236@dejanews.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-11-10T00:00:00+00:00 List-Id: Adam Beneschan wrote: > > GNAT outputs TRUE when I run this program. Is this correct according > to the Ada rules? ObjectAda 7.1 on Windows 95 also reports TRUE. It seems to me that declaring a type in a subprogram should not declare a distinct type each time the subprogram is invoked. Consider the name of the type; Test1.Recursive_Procedure.Type1. This does not change with each invocation. On the other hand, the RM seems pretty clear that they should be distinct: RM 3.2.1(11) The elaboration of a full_type_declaration consists of the elaboration of the full type definition. Each elaboration of a full type definition creates a distinct type and its first subtype. RM 6.3 (7): The execution of a subprogram_body is invoked by a subprogram call. For this execution the declarative_part is elaborated, and the handled_sequence_of_statements is then executed. > > -- thanks, Adam > > with Ada.Tags; > with Text_IO; > > procedure Test1 is > > Tag1 : Ada.Tags.Tag; > Tag2 : Ada.Tags.Tag; > > procedure Recursive_Procedure (N : in Integer) is > > type Type1 is tagged null record; > > type Type2 is new Type1 with record > Some_Data : Integer; > end record; > > begin > if N = 1 then > Tag1 := Type2'Tag; > Recursive_Procedure (2); > else > Tag2 := Type2'Tag; > end if; > end Recursive_Procedure; > > begin > Recursive_Procedure (1); > Text_IO.Put_Line (Boolean'image (Ada.Tags."=" (Tag1, Tag2))); > end Test1; > > -------------------==== Posted via Deja News ====----------------------- > http://www.dejanews.com/ Search, Read, Post to Usenet -- - Stephe