CVS difference for ai05s/ai05-0213-1.txt

Differences between 1.4 and version 1.5
Log of other versions for file ai05s/ai05-0213-1.txt

--- ai05s/ai05-0213-1.txt	2011/04/26 22:28:13	1.4
+++ ai05s/ai05-0213-1.txt	2011/05/12 22:21:37	1.5
@@ -1,11 +1,12 @@
-!standard  3.10.1(9.3/2)                              10-04-28  AI05-0213-1/01
+!standard  3.10.1(8/2)                                11-05-11  AI05-0213-1/02
 !standard  12.5(2)
 !standard  12.5.1(1/2)
 !standard  12.5.1(6)
 !standard  12.5.1(11)
-!standard  12.5.1(17/2)
+!standard  12.5.1(18)
 !standard  13.14(5)
 !class amendment 10-04-28
+!status Amendment 2012 11-05-11
 !status work item 11-04-26
 !status No Action (8-0-2) 10-06-19
 !status work item 10-04-28
@@ -20,7 +21,62 @@
 
 !problem
 
-** TBD **
+Ada 95 provides formal package parameters. One way of using these parameters
+is to define a "signature" for a class of abstractions, such as all set
+abstractions, or all physical unit abstractions, and then build a new
+generic abstraction on top of the original class of abstractions using this
+signature as the template for a formal package parameter.
+
+Unfortunately, it is difficult to use signatures because of the fact that an
+instantiation freezes all of its actual parameters.
+
+For example:
+
+Given the signature for a set abstraction:
+
+generic
+   type Element is private;
+   type Set is private;
+   with function Size(Of_Set : Set) return Natural is <>;
+   with function Union(Left, Right : Set) return Set is <>;
+   with function Intersection(Left, Right : Set) return Set is <>;
+   with function Empty return Set is <>;
+   with function Unit_Set(With_Item : Element) return Set is <>;
+   with function Nth_Element(Of_Set : Set) return Element is <>;
+package Set_Signature is end;
+...
+
+we could define a generic that required some set abstraction, but it
+didn't care which one so long as it implemented the above signature:
+
+generic
+   with package Base_Set is new Set_Signature(<>);
+package Layered_Abstraction is
+   type Cool_Type(Set : access Base_Set.Set) is limited_private;
+   procedure Massage(CT : in out Cool_Type; New_Set : Base_Set.Set);
+   ...
+end Layered_Abstraction;
+
+Now if we want to define a set type and provide the pre-instantiated
+signature for it, we run into trouble:
+
+generic
+   type Elem is private;
+   with function Hash(El : Elem) return Integer;
+package Hashed_Sets is
+
+   type Set is private;
+   function Union(Left, Right : Set) return Set;
+   ...
+
+   package Signature is new Set_Signature(Elem, Set);
+private
+   type Set is record ... end record;
+end Hashed_Sets;
+
+The problem is that we can't do the instantiation of Set_Signature where we
+would want to do so, because the instantiation freezes the type "Set"
+prematurely.
 
 !proposal
 
@@ -28,7 +84,7 @@
 
 !wording
 
-Add a new bullet after 3.10.1(9.3/2):
+Add a new bullet after 3.10.1(8/2):
   *  As a generic actual parameter whose corresponding generic
      formal parameter is a formal incomplete type (see 12.5.1).
 
@@ -60,10 +116,10 @@
    is all types, but [it]{the category} can be restricted to only nonlimited
    types or to only tagged types. {Similarly, the category for a formal
    incomplete type is all types but the category can be restricted to only
-   tagged types.} The category determined for a formal derived type is the
-   derivation class rooted at the ancestor type.
+   tagged types; unlike other formal types, the actual type does not need
+   to be able to be frozen (see 13.14).} The category determined for a formal
+   derived type is the derivation class rooted at the ancestor type.
 
-
 Replace 12.5.1(6):
     If a formal private or derived subtype is definite, then the
     actual subtype shall also be definite.
@@ -77,7 +133,7 @@
     For a generic formal private {or incomplete} type with a
     known_discriminant_part:
 
-Append after 12.5.1(17/2):
+Append after 12.5.1(18):
 
    The category determined for a formal incomplete type is the
    category of all types, unless the formal_type_declaration
@@ -92,22 +148,145 @@
    parameter of the instantiation is defaulted, the default_expression or
    default_name for that parameter causes freezing.
 
-   AARM note: Thus, an actual parameter corresponding to an formal
+   AARM note: Thus, an actual parameter corresponding to a formal
    incomplete type parameter may denote an incomplete or private type
    which is not completely defined at the point of the generic_instantiation.
 
 
 !discussion
 
-** TBD **
+This generic formal is used in the definition of the iterator generic (see
+AI05-0139-2) in order to allow that generic to be visibly instantiated in
+containers packages (see AI05-0212-1).
 
 !example
-
-** TBD **
-
---!corrigendum A.4.4(3)
 
+The set signature shown in the !problem could be written as:
 
+generic
+   type Element is private;
+   type Set;
+   with function Size(Of_Set : Set) return Natural is <>;
+   with function Union(Left, Right : Set) return Set is <>;
+   with function Intersection(Left, Right : Set) return Set is <>;
+   with function Empty return Set is <>;
+   with function Unit_Set(With_Item : Element) return Set is <>;
+   with function Nth_Element(Of_Set : Set) return Element is <>;
+package Set_Signature is end;
+
+Now the instance shown in the !problem is legal.
+
+!corrigendum 3.10.1(8/2)
+
+@dinsa
+@xbullet<as the @fa<subtype_mark> in an @fa<access_definition>.>
+@dinst
+@xbullet<as a generic actual parameter whose corresponding generic
+formal parameter is a formal incomplete type (see 12.5.1).>
+
+!corrigendum 12.5(2)
+
+@drepl
+@xcode<@fa<formal_type_declaration ::=
+    >@b<@ft<type>>@fa< defining_identifier[discriminant_part] >@b<@ft<is>>@fa< formal_type_definition;>>
+@dby
+@xcode<@fa<formal_type_declaration ::=
+    formal_complete_type_declaration
+  | formal_incomplete_type_declaration>>
+
+@xcode<@fa<formal_complete_type_declaration ::=
+    >@b<@ft<type>>@fa< defining_identifier[discriminant_part] >@b<@ft<is>>@fa< formal_type_definition
+      [aspect_specification];>>
+
+@xcode<@fa<formal_incomplete_type_declaration ::=
+    >@b<@ft<type>>@fa< defining_identifier[discriminant_part] [>@b<@ft<is tagged>>@fa<];>>
+
+
+!corrigendum 12.5(6)
+
+@drepl
+The form of a @fa<formal_type_definition> @i<determines a category (of types)>
+to which the formal type belongs. For a @fa<formal_private_type_definition> the
+reserved words @b<tagged> and @b<limited> indicate the category of types (see
+12.5.1). For a @fa<formal_derived_type_definition> the category of types is the
+derivation class rooted at the ancestor type. For other formal types, the name
+of the syntactic category indicates the category of types; a
+@fa<formal_discrete_type_definition> defines a discrete type, and so on.
+@dby
+The form of a @fa<formal_type_definition> @i<determines a category (of types)>
+to which the formal type belongs. For a @fa<formal_private_type_definition> the
+reserved words @b<tagged> and @b<limited> indicate the category of types (see
+12.5.1). The reserved word @b<tagged> also plays this role in the case of a
+@fa<formal_incomplete_type_declaration>.
+For a @fa<formal_derived_type_definition> the category of types is the
+derivation class rooted at the ancestor type. For other formal types, the name
+of the syntactic category indicates the category of types; a
+@fa<formal_discrete_type_definition> defines a discrete type, and so on.
+
+
+!corrigendum 12.5.1(1)
+
+@drepl
+In its most general form, the category determined for a formal private type
+is all types, but it can be restricted to only nonlimited types or to only
+tagged types. The category determined for a formal derived type is the
+derivation class rooted at the ancestor type.
+@dby
+In its most general form, the category determined for a formal private type
+is all types, but the category can be restricted to only nonlimited
+types or to only tagged types. Similarly, the category for a formal
+incomplete type is all types but the category can be restricted to only
+tagged types; unlike other formal types, the actual type does not need
+to be able to be frozen (see 13.14). The category determined for a formal
+derived type is the derivation class rooted at the ancestor type.
+
+!corrigendum 12.5.1(6)
+
+@drepl
+If the formal subtype is definite, then the
+actual subtype shall also be definite.
+@dby
+If a formal private or derived subtype is definite, then the
+actual subtype shall also be definite.
+
+A @fa<formal_incomplete_type_declaration> declares a formal incomplete type.
+The only view of a formal incomplete type is an incomplete view.
+Thus, a formal incomplete type is subject to the same
+usage restrictions as any other incomplete type - see 3.10.1.
+
+!corrigendum 12.5.1(11)
+
+@drepl
+The declaration of a formal derived type shall not have a @fa<known_discriminant_part>.
+For a generic formal private type with a @fa<known_discriminant_part>: 
+@dby
+The declaration of a formal derived type shall not have a @fa<known_discriminant_part>.
+For a generic formal private or incomplete type with a @fa<known_discriminant_part>: 
+
+!corrigendum 12.5.1(18)
+
+@dinsa
+The presence of the reserved word @b<abstract> determines whether the actual type
+may be abstract.
+@dinst
+The category determined for a formal incomplete type is the
+category of all types, unless the @fa<formal_type_declaration>
+includes the reserved word @b<tagged>; in this case, it is the
+category of all tagged types.
+
+!corrigendum 13.14(5)
+
+@drepl
+@xbullet<The occurrence of a @fa<generic_instantiation> causes freezing; also, if
+a parameter of the instantiation is defaulted, the @fa<default_expression> or
+@fa<default_name> for that parameter causes freezing.>
+@dby
+@xbullet<The occurrence of a @fa<generic_instantiation> causes freezing, except that
+a @fa<name> which is a generic actual parameter whose corresponding
+generic formal parameter is a formal incomplete type (see 12.5.1)
+does not cause freezing. In addition, if a
+parameter of the instantiation is defaulted, the @fa<default_expression> or
+@fa<default_name> for that parameter causes freezing.>
 
 !ACATS test
 

Questions? Ask the ACAA Technical Agent