Annotated Ada Reference ManualLegal Information
Table of Contents   Index   References   Search   Previous   Next 

 3.3 Objects and Named Numbers

1
[Objects are created at run time and contain a value of a given type. {creation (of an object)} An object can be created and initialized as part of elaborating a declaration, evaluating an allocator, aggregate, or function_call, or passing a parameter by copy. Prior to reclaiming the storage for an object, it is finalized if necessary (see 7.6.1).]

Static Semantics

2
{object} All of the following are objects: 
2.a
Glossary entry: {Object} An object is either a constant or a variable. An object contains a value. An object is created by an object_declaration or by an allocator. A formal parameter is (a view of) an object. A subcomponent of an object is an object.
3
4
5
6
7
8
9
10/2
11
12
13
{constant} {variable} {constant object} {variable object} {constant view} {variable view} An object is either a constant object or a variable object. The value of a constant object cannot be changed between its initialization and its finalization, whereas the value of a variable object can be changed. Similarly, a view of an object is either a constant or a variable. All views of a constant object are constant. A constant view of a variable object cannot be used to modify the value of the variable. The terms constant and variable by themselves refer to constant and variable views of objects.
14
{read (the value of an object)} The value of an object is read when the value of any part of the object is evaluated, or when the value of an enclosing object is evaluated. {update (the value of an object)} The value of a variable is updated when an assignment is performed to any part of the variable, or when an assignment is performed to an enclosing object.
14.a
Ramification: Reading and updating are intended to include read/write references of any kind, even if they are not associated with the evaluation of a particular construct. Consider, for example, the expression “X.all(F)”, where X is an access-to-array object, and F is a function. The implementation is allowed to first evaluate “X.all” and then F. Finally, a read is performed to get the value of the F'th component of the array. Note that the array is not necessarily read as part of the evaluation of “X.all”. This is important, because if F were to free X using Unchecked_Deallocation, we want the execution of the final read to be erroneous. 
15
Whether a view of an object is constant or variable is determined by the definition of the view. The following (and no others) represent constants: 
16
16.a/2
To be honest: {AI95-00385-01} We mean the word constant as defined by the grammar for object_declaration, not some random word constant. Thus, 
16.b/2
X : access constant T;
16.c/2
is not a constant.
17
18
19
20
21
22
22.a/2
This paragraph was deleted.To be honest: {AI95-00114-01} A noninvertible view conversion to a general access type is also defined to be a constant — see 4.6.
23
{nominal subtype} At the place where a view of an object is defined, a nominal subtype is associated with the view. {actual subtype} {subtype (of an object): See actual subtype of an object} The object's actual subtype (that is, its subtype) can be more restrictive than the nominal subtype of the view; it always is if the nominal subtype is an indefinite subtype. {indefinite subtype} {definite subtype} A subtype is an indefinite subtype if it is an unconstrained array subtype, or if it has unknown discriminants or unconstrained discriminants without defaults (see 3.7); otherwise the subtype is a definite subtype [(all elementary subtypes are definite subtypes)]. [A class-wide subtype is defined to have unknown discriminants, and is therefore an indefinite subtype. An indefinite subtype does not by itself provide enough information to create an object; an additional constraint or explicit initialization expression is necessary (see 3.3.1). A component cannot have an indefinite nominal subtype.]
24
{named number} A named number provides a name for a numeric value known at compile time. It is declared by a number_declaration.
NOTES
25
5  A constant cannot be the target of an assignment operation, nor be passed as an in out or out parameter, between its initialization and finalization, if any.
26
6  The nominal and actual subtypes of an elementary object are always the same. For a discriminated or array object, if the nominal subtype is constrained then so is the actual subtype.

Extensions to Ada 83

26.a
{extensions to Ada 83} There are additional kinds of objects (choice parameters and entry indices of entry bodies).
26.b
The result of a function and of evaluating an aggregate are considered (constant) objects. This is necessary to explain the action of finalization on such things. Because a function_call is also syntactically a name (see 4.1), the result of a function_call can be renamed, thereby allowing repeated use of the result without calling the function again. 

Wording Changes from Ada 83

26.c
This clause and its subclauses now follow the clause and subclauses on types and subtypes, to cut down on the number of forward references.
26.d
The term nominal subtype is new. It is used to distinguish what is known at compile time about an object's constraint, versus what its "true" run-time constraint is.
26.e
The terms definite and indefinite (which apply to subtypes) are new. They are used to aid in the description of generic formal type matching, and to specify when an explicit initial value is required in an object_declaration.
26.f
We have moved the syntax for object_declaration and number_declaration down into their respective subclauses, to keep the syntax close to the description of the associated semantics.
26.g
We talk about variables and constants here, since the discussion is not specific to object_declarations, and it seems better to have the list of the kinds of constants juxtaposed with the kinds of objects.
26.h
We no longer talk about indirect updating due to parameter passing. Parameter passing is handled in 6.2 and 6.4.1 in a way that there is no need to mention it here in the definition of read and update. Reading and updating now includes the case of evaluating or assigning to an enclosing object. 

Wording Changes from Ada 95

26.i/2
{AI95-00416-01} Clarified that the return object is the object created by a function call. 

Table of Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe