Annotated Ada Reference ManualLegal Information
Table of Contents   Index   References   Search   Previous   Next 

 12.5.3 Formal Array Types

1/2
{AI95-00442-01} [The category class determined for a formal array type is the category class of all array types.] 
1.a/2
Proof: {AI95-00442-01} This rule follows from the rule in 12.5 that says that the category is determined by the one given in the name of the syntax production. The effect of the rule is repeated here to give a capsule summary of what this subclause is about. 

Syntax

2
formal_array_type_definition ::= array_type_definition

Legality Rules

3
The only form of discrete_subtype_definition that is allowed within the declaration of a generic formal (constrained) array subtype is a subtype_mark
3.a
Reason: The reason is the same as for forbidding constraints in subtype_indications (see 12.1). 
4
For a formal array subtype, the actual subtype shall satisfy the following conditions: 
5
6
7
8
8.a
Ramification: On the other hand, if the formal's components are not aliased, then the actual's components can be either aliased or not. 

Examples

9
Example of formal array types: 
10
--  given the generic package 
11
generic
   type Item   is private;
   type Index  is (<>);
   type Vector is array (Index range <>) of Item;
   type Table  is array (Index) of Item;
package P is
   ...
end P;
12
--  and the types 
13
type Mix    is array (Color range <>) of Boolean;
type Option is array (Color) of Boolean;
14
--  then Mix can match Vector and Option can match Table 
15
package R is new P(Item   => Boolean, Index => Color,
                   Vector => Mix,     Table => Option);
16
--  Note that Mix cannot match Table and Option cannot match Vector

Incompatibilities With Ada 83

16.a
{incompatibilities with Ada 83} The check for matching of component subtypes and index subtypes or index ranges is changed from a run-time check to a compile-time check. The Ada 83 rule that “If the component type is not a scalar type, then the component subtypes shall be either both constrained or both unconstrained” is removed, since it is subsumed by static matching. Likewise, the rules requiring that component types be the same is subsumed. 

Wording Changes from Ada 95

16.b/2
{AI95-00442-01} We change to “determines a category” as that is the new terminology (it avoids confusion, since not all interesting properties form a class). 

Table of Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe