Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
 
Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

8.5.1 Object Renaming Declarations

1
An object_renaming_declaration is used to rename an object. 

Syntax

2/3
object_renaming_declaration ::= 
    defining_identifier : [null_exclusionsubtype_mark renames object_name
        [aspect_specification];
  | defining_identifier : access_definition renames object_name
        [aspect_specification];

Name Resolution Rules

3/2
The type of the object_name shall resolve to the type determined by the subtype_mark, or in the case where the type is defined by an access_definition, to an anonymous access type. If the anonymous access type is an access-to-object type, the type of the object_name shall have the same designated type as that of the access_definition. If the anonymous access type is an access-to-subprogram type, the type of the object_name shall have a designated profile that is type conformant with that of the access_definition.

Legality Rules

4
The renamed entity shall be an object.
4.1/2
  In the case where the type is defined by an access_definition, the type of the renamed object and the type defined by the access_definition:
4.2/2
shall both be access-to-object types with statically matching designated subtypes and with both or neither being access-to-constant types; or
4.3/2
shall both be access-to-subprogram types with subtype conformant designated profiles.
4.4/2
  For an object_renaming_declaration with a null_exclusion or an access_definition that has a null_exclusion:
4.5/2
if the object_name denotes a generic formal object of a generic unit G, and the object_renaming_declaration occurs within the body of G or within the body of a generic unit declared within the declarative region of G, then the declaration of the formal object of G shall have a null_exclusion;
4.6/2
otherwise, the subtype of the object_name shall exclude null. In addition to the places where Legality Rules normally apply (see 12.3), this rule applies also in the private part of an instance of a generic unit.
5/3
The renamed entity shall not be a subcomponent that depends on discriminants of an object whose nominal subtype is unconstrained unless the object is known to be constrained. A slice of an array shall not be renamed if this restriction disallows renaming of the array. In addition to the places where Legality Rules normally apply, these rules apply also in the private part of an instance of a generic unit.

Static Semantics

6/2
An object_renaming_declaration declares a new view of the renamed object whose properties are identical to those of the renamed view. Thus, the properties of the renamed object are not affected by the renaming_declaration. In particular, its value and whether or not it is a constant are unaffected; similarly, the null exclusion or constraints that apply to an object are not affected by renaming (any constraint implied by the subtype_mark or access_definition of the object_renaming_declaration is ignored). 

Examples

7
Example of renaming an object: 
8
declare
   L : Person renames Leftmost_Person; -- see 3.10.1
begin
   L.Age := L.Age + 1;
end;

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe