3.7.1 Discriminant Constraints
Name Resolution Rules
of a named discriminant_association
shall resolve to denote a discriminant of the subtype being constrained;
the discriminants so named are the associated
of the named association.
positional association, the associated discriminant
is the one
occurred in the corresponding position in the known_discriminant_part
that defined the discriminants of the subtype being constrained.
is only allowed in a subtype_indication
denotes either an unconstrained discriminated subtype, or an unconstrained
access subtype whose designated subtype is an unconstrained discriminated
subtype. However, in the case of an access subtype, a discriminant_constraint
is illegal if the designated type has a partial view that is constrained
or, for a general access subtype, has default_expression
for its discriminants. In addition to the places where Legality Rules
normally apply (see 12.3
), these rules apply
also in the private part of an instance of a generic unit. In a generic
body, this rule is checked presuming all formal access types of the generic
might be general access types, and all untagged discriminated formal
types of the generic might have default_expression
for their discriminants.
associated with an access discriminant shall be of a type convertible
to the anonymous access type.
with an unconstrained discriminated subtype if each
discriminant value belongs to the subtype of the corresponding discriminant.
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.
For the elaboration of a discriminant_constraint
in the discriminant_association
are evaluated in an arbitrary order and converted to the type of the
associated discriminant (which might raise Constraint_Error — see
); the expression
of a named association is evaluated (and converted) once for each associated
The result of each evaluation and conversion
is the value imposed by the constraint for the associated discriminant.
56 The rules of the language ensure that
a discriminant of an object always has a value, either from explicit
or implicit initialization.
types declared above in clause 3.7):
Large : Buffer(200); -- constrained, always 200 characters
-- (explicit discriminant value)
Message : Buffer; -- unconstrained, initially 100 characters
-- (default discriminant value)
Basis : Square(5); -- constrained, always 5 by 5
Illegal : Square; -- illegal, a Square has to be constrained