DocAda(tm) is a productivity tool of KSCE

____ | Up | Next | Back | Forward
About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News

3.6.1 Index Constraints and Discrete Ranges

An index_constraint determines the range of possible values for every index of an array subtype, and thereby the corresponding array bounds.

Syntax

   
       index_constraint ::=  (discrete_range {, discrete_range})

       discrete_range ::= discrete_subtype_indication | range

Name Resolution Rules

The type of a discrete_range is the type of the subtype defined by the subtype_indication, or the type of the range. For an index_constraint, each discrete_range shall resolve to be of the type of the corresponding index.

Legality Rules

An index_constraint shall appear only in a subtype_indication whose subtype_mark denotes either an unconstrained array subtype, or an unconstrained access subtype whose designated subtype is an unconstrained array subtype; in either case, the index_constraint shall provide a discrete_range for each index of the array type.

Static Semantics

A discrete_range defines a range whose bounds are given by the range, or by the range of the subtype defined by the subtype_indication.

Dynamic Semantics

An index_constraint is compatible with an unconstrained array subtype if and only if the index range defined by each discrete_range is compatible (see 3.5) with the corresponding index subtype. If any of the discrete_ranges defines a null range, any array thus constrained is a null array, having no components. An array value satisfies an index_constraint if at each index position the array value and the index_constraint have the same index bounds.

The elaboration of an index_constraint consists of the evaluation of the discrete_range(s), in an arbitrary order. The evaluation of a discrete_range consists of the elaboration of the subtype_indication or the evaluation of the range.

Examples

Examples of array declarations including an index constraint:

    
       Board     : Matrix(1 .. 8,  1 .. 8);  --  see 3.6
       Rectangle : Matrix(1 .. 20, 1 .. 30);
       Inverse   : Matrix(1 .. N,  1 .. N);  --  N need not be static

       Filter    : Bit_Vector(0 .. 31);

Example of array declaration with a constrained array subtype:

    
       My_Schedule : Schedule;  --  all arrays of type Schedule have the same bounds

Example of record type with a component that is an array:

    
       type Var_Line(Length : Natural) is
          record
             Image : String(1 .. Length);
          end record;

       Null_Line : Var_Line(0);  --  Null_Line.Image is a null array

About DocAda Light: Preface / Preliminary / Help / TOC / Copyright
DocAda Online at the Ada Home: Complete RM95 / Updates / News
____ | Up | Next | Back | Forward


Copyright © 1994-1997 by Kempe Software Capital Enterprises. All Rights Reserved. For comments on this DocAda(tm) hypertext document, please write to KSCE, at docada@ksce.com