!standard 03.10.01 (02) 03-02-11 AI95-00326/01 !standard 03.10.01 (04) !standard 03.10.01 (05) !standard 03.10.01 (08) !standard 03.10.01 (09) !standard 03.10.01 (10) !standard 03.10.01 (11) !standard J.11 (00) !class amendment 02-02-06 !status work item 02-12-13 !status received 02-02-06 !priority Medium !difficulty Medium !subject Tagged incomplete types !summary A concept of a "tagged incomplete" type is introduced, which is a type that has the same restrictions as an incomplete type except that it may also be used for a formal or actual parameter. !problem For mutually recursive types, it is valuable if subprogram parameters may be of the type itself, rather than only an access to the type. However, for most types, it may be necessary to see the full definition to know how parameters of the type are passed. However, because tagged types are always passed by reference, there is no implementation difficulty in allowing them to be used as parameters even when the full definition of the type is not available. Hence, it makes sense to relax the rule for using incomplete types that are known to be tagged, to allow them as formal and actual parameters, since from a code generation point of view they are essentially equivalent to access parameters. !proposal The syntax for an incomplete type declaration is amended as follows: incomplete_type_declaration ::= TYPE defining_identifier [discriminant_part] [IS TAGGED]; If the words IS TAGGED appear, the type is a tagged incomplete type. Otherwise, the type is a non-tagged incomplete type. In addition to places where a (non-tagged) incomplete type may be used, a tagged incomplete type may be used as a formal parameter type, and as an actual parameter that is a dereference of an access-to-tagged-incomplete value. The attribute 'Class is defined for (specific) tagged incomplete types. (The use of 'Class with non-tagged incomplete types is considered obsolescent; such non-tagged incomplete types must be completed with a tagged type.) The class-wide type denoted by the Class attribute of an incomplete tagged type is also an incomplete tagged type. An incomplete tagged type declaration must be completed by a tagged type declaration. !wording Replace 3.10.1(2): incomplete_type_declaration ::= TYPE defining_identifier [discriminant_part] [IS TAGGED]; Modify 3.10.1(4): Add a new first sentence: If an incomplete_type_declaration includes the keyword TAGGED, then a type_declaration that completes it shall declare a tagged type. Replace 3.10.1(5-9): A name that denotes an incomplete_type_declaration may be used as follows: * as the subtype_mark in the subtype_indication of an access_to_object_definition; the only form of constraint allowed in this subtype_indication is a discriminant_constraint; * as the subtype_mark defining the subtype of a parameter or result of an access_to_subprogram_definition; * as the subtype_mark in an access_definition; A name that denotes an incomplete_type_declaration that includes the keyword TAGGED may also be used as follows: * as the subtype_mark defining the subtype of a parameter in a formal_part; * as the prefix of an attribute_reference whose attribute_designator is Class; such an attribute_reference is restricted to the uses allowed above. Replace 3.10.1(11): An incomplete_type_declaration declares an incomplete type and its first subtype; the incomplete type is tagged if the keyword TAGGED appears; the first subtype is unconstrained if a known_discriminant_part appears. Add J.11: J.11 The Class Attribute of Non-tagged Incomplete Types For the first subtype S of a type T declared by an incomplete_type_declaration that is not tagged, the following attribute is defined: S'Class Denotes the first subtype of the incomplete class-wide type rooted at T. The completion of T shall declare a tagged type. Such an attribute reference shall occur in the same library unit as the incomplete_type_declaration. !discussion Tagged type hierarchies often have need for mutually dependent types. By allowing a tagged incomplete type to be used as a formal parameter type, access parameters may be avoided in such mutually dependent type situations. This proposal gains additional power when combined with the proposals for allowing mutually dependent types to be defined in separate packages. We are not allowing an incomplete tagged type to be used as a return type, because of the many special rules and implementation issues associated with returning tagged types (e.g. abstract types may not be used as result types, functions that must be overridden, accessibility checks on returning limited by-reference types, dispatching on result coupled with tag indeterminacy, finalization associated with returning potentially controlled types, etc.). !example !corrigendum 3.10.1(2) @drepl @xindent<@fa defining_identifier [discriminant_part];>> @dby @xindent<@fa defining_identifier [discriminant_part] [@b]; !corrigendum 3.10.1(4) @drepl If an @fa has a @fa, then a @fa that completes it shall have a fully conforming (explicit) @fa (see 6.3.1). If an @fa has no @fa (or an @fa), then a corresponding @fa is nevertheless allowed to have discriminants, either explicitly, or inherited via derivation. @dby If an @fa includes the keyword @b, then a @fa that completes it shall declare a tagged type. If an @fa has a @fa, then a @fa that completes it shall have a fully conforming (explicit) @fa (see 6.3.1). If an @fa has no @fa (or an @fa), then a corresponding @fa is nevertheless allowed to have discriminants, either explicitly, or inherited via derivation. !corrigendum 3.10.1(5) @drepl The only allowed uses of a name that denotes an @fa are as follows: @dby A name that denotes an @fa may be used as follows: !corrigendum 3.10.1(8) @drepl @xbullet in an @fa;> @dby @xbullet in an @fa.> A name that denotes an incomplete_type_declaration that includes the keyword @b may also be used as follows: @xbullet defining the subtype of a parameter in a @fa;> !corrigendum 3.10.1(9) @drepl @xbullet of an @fa whose @fa is Class; such an @fa is similarly restricted to the uses allowed here; when used in this way, the corresponding @fa shall declare a tagged type, and the @fa shall occur in the same library unit as the @fa.> @dby @xbullet of an @fa whose @fa is Class; such an @fa is restricted to the uses allowed above.> !corrigendum 3.10.1(11) @drepl An @fa declares an incomplete type and its first subtype; the first subtype is unconstrained if a @fa appears. @dby An @fa declares an incomplete type and its first subtype; the incomplete type is tagged if the keyword @b appears; the first subtype is unconstrained if a @fa appears. !corrigendum J.11(1) @dinsc For the first subtype S of a type T declared by an @fa that is not tagged and is not a type stub, the following attribute is defined: @xhang<@xtermDenotes the first subtype of the incomplete class-wide type rooted at T. The completion of T shall declare a tagged type. Such an attribute reference shall occur in the same library unit as the @fa. !ACATS Test ACATS B and C tests should be constructed for this AI. !appendix This AI was split out of AI-00217-05 (and other variants), in order to simplify those proposals and to insure that this idea gets considered no matter which of those proposals is adopted. *************************************************************