Ada '83 Language Reference Manual
Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.
4.9. Static Expressions and Static Subtypes
Certain expressions of a scalar type are said to be static. Similarly,
certain discrete ranges are said to be static, and the type marks of
certain scalar subtypes are said to denote static subtypes.
An expression of a scalar type is said to be static if and only if every
primary is one of those listed in (a) through (h) below, every operator
denotes a predefined operator, and the evaluation of the expression
delivers a value (that is, it does not raise an exception):
- An enumeration literal (including a character literal).
- A numeric literal.
- A named number.
- A constant explicitly declared by a constant declaration with a static
subtype, and initialized with a static expression.
- A function call whose function name is an operator symbol that denotes
a predefined operator, including a function name that is an expanded
name; each actual parameter must also be a static expression.
- A language-defined attribute of a static subtype; for an attribute
that is a function, the actual parameter must also be a static
expression.
- A qualified expression whose type mark denotes a static subtype and
whose operand is a static expression.
- A static expression enclosed in parentheses.
A static range is a range whose bounds are static expressions. A static
range constraint is a range constraint whose range is static. A static
subtype is either a scalar base type, other than a generic formal type; or
a scalar subtype formed by imposing on a static subtype either a static
range constraint, or a floating or fixed point constraint whose range
constraint, if any, is static. A static discrete range is either a static
subtype or a static range. A static index constraint is an index
constraint for which each index subtype of the corresponding array type is
static, and in which each discrete range is static. A static discriminant
constraint is a discriminant constraint for which the subtype of each
discriminant is static, and in which each expression is static.
Notes:
The accuracy of the evaluation of a static expression having a real type is
defined by the rules given in section 4.5.7. If the result is not a model
number (or a safe number) of the type, the value obtained by this
evaluation at compilation time need not be the same as the value that would
be obtained by an evaluation at run time.
Array attributes are not static: in particular, the RANGE attribute is not
static.
References: actual parameter,
attribute,
base type,
bound of a range,
character literal,
constant,
constant declaration,
discrete range,
discrete type,
enumeration literal,
exception,
expression,
function,
generic actual parameter,
generic formal type,
implicit declaration,
initialize,
model number,
named number,
numeric literal,
predefined operator,
qualified expression,
raising of exceptions,
range constraint,
safe number,
scalar type,
subtype,
type mark.
Rationale references:
3.6 Expressions,
4.4.2 Subtypes
Style Guide references:
3.2.5 Constants and Named Numbers,
7.2.6 Precision of Constants,
8.2.1 Named Numbers
Address any questions or comments to
adainfo@sw-eng.falls-church.va.us.