Version 1.1 of ais/ai-00382.txt

Unformatted version of ais/ai-00382.txt version 1.1
Other versions for file ais/ai-00382.txt

!standard 8.6(17)          04-08-27 AI95-00382/01
!class amendment 04-08-27
!status work item 04-08-27
!status received 04-08-27
!priority Medium
!difficulty Medium
!subject Current instance rule and anonymous access types
(See Proposal.)
AI95-00230 introduces the capability to use anonymous access types in a number of new contexts, in particular in component_definitions. It appears however that the current instance rule of 8.6(17) creates illegalities when an anonymous access type is used as the type of a component. This is demonstrated by the following example, excerpted from AI95-00230:
type Obj is record M : Integer; Next : access Obj; end record;
This example is likely to be very typical of user code, as linked structure are ubiquitous. Therefore, one would very much like it to be legal, as it avoids the declaration of a named access type. However, the current instance rule states that Obj in the record type declaration is the name of an object or value, so the construct "access Obj" is meaningless and therefore illegal.
We are changing the current instance rule for type so that the type name occurring in a access_definition does not denote the current instance of the type, but rather the type itself. We only do this for access-to-object types. The type name occurring as the parameter or result type for an (anonymous) access-to-subprogram type is still illegal.
Note that we are not changing the rules for named access types (the current instance problem for named access types can only occur in task and protected bodies).
A few examples of the effect of the new rule:
type Obj is record M : Integer; Next : access Obj; -- Legal Callback1 : access procedure (X : access Obj); -- Legal Callback2 : access procedure (X : Obj); -- Illegal end record;
task type T;
task body T is X : array (1..2) of access T; -- Legal type A is access all T; -- Illegal procedure P (X : access T) is ... end P; -- Legal procedure P (X : T) is ... end P; -- Illegal begin ... end T;
Replace 8.6(17) by:
If a usage name appears within the declarative region of a type_declaration, denotes that same type_declaration, but is not the subtype_mark of an access_definition for a general access type, then it denotes the current instance of the type (rather than the type itself). The current instance of a type is the object or value of the type that is associated with the execution that evaluates the usage name.
See proposal.
!ACATS test
ACATS tests need to be constructed for this rule.


Questions? Ask the ACAA Technical Agent