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,2813882933f323d0 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Recursive tagged types Date: 1997/11/10 Message-ID: #1/1 X-Deja-AN: 288424938 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <34675FB1.7C8@gsfc.nasa.gov> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-11-10T00:00:00+00:00 List-Id: Stephen Leake (Stephen.Leake@gsfc.nasa.gov) wrote: : 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. Both are correct. A tag identifies the "full_type_declaration" of the type, per RM95 3.9(4) . There is only one of these, even though there are conceptually multiple types, one per invocation of the recursive procedure. : 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: It is true that these are distinct *types* (which are run-time things) but they are not distinct type *declarations* (which are compile-time constructs). Note that distinct generic instantiations generally do produce distinct type *declarations* in each instance, and these are required to have distinct tags (at least for types declared in the package spec). Note that the language *allows* tags to be different on each elaboration of the type declaration, but does not require it (need to read the AARM 3.9(4.b) to see a discussion of this), because the identification goes only one way. That is, the tag identifies the declaration, but the declaration does not necessarily uniquely determine the tag. However, in essentially all implementations, one expects all elaborations of a given type declaration to result in the same tag. The one exception might be for implementations that share code between generic instantiations. These might generate a new tag for each elaboration if a generic instantiation occurs inside a subprogram. In general, one expects the implementation of tags to be similar to the implementation of exceptions, that is only one per declaration, rather than one per elaboration of the declaration. Another way of thinking about it is that if the full expanded names of two types are the same, then their tags may be the same. : 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. Right, it creates a distinct *type* but not a distinct type declaration, which is a compile-time thing. : ... : - Stephe -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA