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

 4.9.1 Statically Matching Constraints and Subtypes

Static Semantics

1/2
{AI95-00311-01} {statically matching (for constraints)} A constraint statically matches another constraint if: both are null constraints, both are static and have equal corresponding bounds or discriminant values, or both are nonstatic and result from the same elaboration of a constraint of a subtype_indication or the same evaluation of a range of a discrete_subtype_definition.
1.1/2
1.2/2
1.3/2
1.4/2
2/2
{AI95-00231-01} {AI95-00254-01} {statically matching (for subtypes)} A subtype statically matches another subtype of the same type if they have statically matching constraints, and, for access subtypes, either both or neither exclude null. Two anonymous access-to-object subtypes statically match if their designated subtypes statically match, and either both or neither exclude null, and either both or neither are access-to-constant. Two anonymous access-to-subprogram subtypes statically match if their designated profiles are subtype conformant, and either both or neither exclude null
2.a
Ramification: Statically matching constraints and subtypes are the basis for subtype conformance of profiles (see 6.3.1).
2.b/2
Reason: Even though anonymous access types always represent different types, they can statically match. That's important so that they can be used widely. For instance, if this wasn't true, access parameters and access discriminants could never conform, so they couldn't be used in separate specifications.
3
{statically matching (for ranges)} Two ranges of the same type statically match if both result from the same evaluation of a range, or if both are static and have equal corresponding bounds. 
3.a
Ramification: The notion of static matching of ranges is used in 12.5.3, “Formal Array Types”; the index ranges of formal and actual constrained array subtypes have to statically match. 
4
{statically compatible (for a constraint and a scalar subtype)} A constraint is statically compatible with a scalar subtype if it statically matches the constraint of the subtype, or if both are static and the constraint is compatible with the subtype. {statically compatible (for a constraint and an access or composite subtype)} A constraint is statically compatible with an access or composite subtype if it statically matches the constraint of the subtype, or if the subtype is unconstrained. {statically compatible (for two subtypes)} One subtype is statically compatible with a second subtype if the constraint of the first is statically compatible with the second subtype. 
4.a
Discussion: Static compatibility is required when constraining a parent subtype with a discriminant from a new discriminant_part. See 3.7. Static compatibility is also used in matching generic formal derived types.
4.b
Note that statically compatible with a subtype does not imply compatible with a type. It is OK since the terms are used in different contexts. 

Wording Changes from Ada 83

4.c
This subclause is new to Ada 95. 

Wording Changes from Ada 95

4.d/2
{AI95-00231-01} {AI95-00254-01} Added static matching rules for null exclusions and anonymous access-to-subprogram types; both of these are new in Ada 2005.
4.e/2
{AI95-00311-01} We clarify that the constraint of the first subtype of a scalar formal type statically matches itself. 

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