'Valid_Scalars attribute is intended to make it easier to check the
validity of scalar subcomponents of composite objects. The attribute is defined
for any prefix
P which denotes an object. Prefix
P can be any type
except for tagged private or
Unchecked_Union types. The value of the
attribute is of type
True if and only if the evaluation of
True for every scalar subcomponent
P, or if
P has no scalar subcomponents. Attribute
'Valid_Scalars is equivalent
'Valid for scalar types.
It is not specified in what order the subcomponents are checked, nor whether
any more are checked after any one of them is determined to be invalid. If the
P is of a class-wide type
T is the associated
specific type), or if the prefix
P is of a specific tagged type
only the subcomponents of
T are checked; in other words, components of
T are not checked even if
T'Class (P)'Tag /= T'Tag.
The compiler will issue a warning if it can be determined at compile time that the prefix of the attribute has no scalar subcomponents.
Valid_Scalars can generate a lot of code, especially in the case of
a large variant record. If the attribute is called in many places in the same
program applied to objects of the same type, it can reduce program size to
write a function with a single use of the attribute, and then call that
function from multiple places.