1

A discriminant_constraint
specifies the values of the discriminants for a given discriminated type.

1.a

The rules in this clause are intentionally
parallel to those given in Record Aggregates.

2

3

discriminant_association
::=

[*discriminant_*selector_name {| *discriminant_*selector_name} =>] expression

[

4

{*named discriminant association*}
A discriminant_association
is said to be *named* if it has one or more *discriminant_*selector_names;
{*positional discriminant association*} it
is otherwise said to be *positional*. In a discriminant_constraint,
any positional associations shall precede any named associations.

5

Each selector_name
of a named discriminant_association
shall resolve to denote a discriminant of the subtype being constrained;
{*associated discriminants (of a named discriminant_association)*}
the discriminants so named are the *associated
discriminants* of the named association. {*associated
discriminants (of a positional discriminant_association)*}
For a positional association, the *associated discriminant*
is the one whose discriminant_specification
occurred in the corresponding position in the known_discriminant_part
that defined the discriminants of the subtype being constrained.

6

{*expected type (discriminant_association
expression)* [partial]} The expected type
for the expression in a discriminant_association
is that of the associated discriminant(s).

7/1

{*8652/0008*}
A discriminant_constraint is only allowed
in a subtype_indication whose subtype_mark
denotes either an unconstrained discriminated subtype, or an unconstrained access
subtype whose designated subtype is an unconstrained discriminated subtype.
__However, in the case of a general access subtype, a discriminant_constraint
is illegal if there is a place within the immediate scope of the designated
subtype where the designated subtype's view is constrained.__

7.a.1/1

8

A named discriminant_association
with more than one selector_name
is allowed only if the named discriminants are all of the same type.
A discriminant_constraint shall
provide exactly one value for each discriminant of the subtype being
constrained.

9

The expression
associated with an access discriminant shall be of a type convertible
to the anonymous access type. {*convertible (required)*
[partial]}

9.a

10

{*compatibility (discriminant
constraint with a subtype)* [partial]} A
discriminant_constraint is *compatible*
with an unconstrained discriminated subtype if each discriminant value
belongs to the subtype of the corresponding discriminant.

10.a

10.b

11

{*satisfies (a discriminant constraint)*
[partial]} A composite value *satisfies*
a discriminant constraint if and only if each discriminant of the composite
value has the value imposed by the discriminant constraint.

12

{*elaboration (discriminant_constraint)*
[partial]} For the elaboration of a discriminant_constraint,
the expressions in the discriminant_associations
are evaluated in an arbitrary order and converted to the type of the associated
discriminant (which might raise Constraint_Error -- see 4.6);
the expression of a named association is
evaluated (and converted) once for each associated discriminant. {*implicit
subtype conversion (discriminant values)* [partial]} The
result of each evaluation and conversion is the value imposed by the constraint
for the associated discriminant.

12.a

NOTES

13

54 The rules of the language
ensure that a discriminant of an object always has a value, either from
explicit or implicit initialization.

13.a

14

15

Message : Buffer;

Basis : Square(5);

Illegal : Square;

15.a

{*inconsistencies with Ada 83*} Dependent
compatibility checks are no longer performed on subtype declaration. Instead
they are deferred until object creation (see 3.3.1).
This is upward compatible for a program that does not raise Constraint_Error.

15.b

Everything in RM83-3.7.2(7-12),
which specifies the initial values for discriminants, is now redundant
with 3.3.1, 6.4.1, 8.5.1, and 12.4. Therefore, we don't repeat it here.
Since the material is largely intuitive, but nevertheless complicated
to state formally, it doesn't seem worth putting it in a "NOTE."