Ada Programming/Attributes/'Valid Scalars

Description
The  attribute is intended to make it easier to check the validity of scalar subcomponents of composite objects. The attribute is defined for any prefix  which denotes an object. Prefix  can be any type except for tagged private or   types. The value of the attribute is of type.

yields  if and only if the evaluation of   yields   for every scalar subcomponent   of , or if   has no scalar subcomponents. Attribute  is equivalent to attribute   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 prefix  is of a class-wide type   (where   is the associated specific type), or if the prefix   is of a specific tagged type , then only the subcomponents of   are checked; in other words, components of extensions of   are not checked even if.

The compiler will issue a warning if it can be determined at compile time that the prefix of the attribute has no scalar subcomponents.

Note:  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.