Version 1.6 of ais/ai-00382.txt

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

!standard 8.6(17)          05-07-20 AI95-00382/05
!standard 9.1(19)
!standard 9.4(21)
!class amendment 04-08-27
!status Amendment 200Y 04-12-01
!status ARG Approved 8-0-2 04-11-19
!status work item 04-08-27
!status received 04-08-27
!priority Medium
!difficulty Medium
!subject Current instance rule and anonymous access types
!summary
(See proposal.)
!problem
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 structures 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.
!proposal
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.
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); -- Legal 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;
!wording
Replace 8.6(17) by:
If a usage name appears within the declarative region of a type_declaration and denotes that same type_declaration, 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. This rule does not apply if the usage name appears within the subtype_mark of an access_definition for an access-to-object type, or within the subtype of a parameter or result of an access-to-subprogram type.
AARM NOTE: The phrase "within the subtype_mark" is intended to cover a case like "access T'Class" appearing within the declarative region of T: here T denotes the type, not the current instance.
Replace 9.1(19) by:
2 Other than in an access_definition, the name of a task unit within the declaration or body of the task unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding task type (and thus the name cannot be used as a subtype_mark).
Replace 9.4(21) by:
13 Within the declaration or body of a protected unit other than in an access_definition, the name of the protected unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding protected type (and thus the name cannot be used as a subtype_mark).
!discussion
(See proposal.)
!example
Here is an example involving a linked structure with an anonymous access type:
type Obj is record M : Integer; Next : access Obj; end record;
!corrigendum 8.6(17)
Replace the paragraph:
If a usage name appears within the declarative region of a type_declaration and denotes that same type_declaration, 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.
by:
If a usage name appears within the declarative region of a type_declaration and denotes that same type_declaration, 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. This rule does not apply if the usage name appears within the subtype_mark of an access_definition for an access-to-object type, or within the subtype of a parameter or result of an access-to-subprogram type.
!corrigendum 9.1(19)
Replace the paragraph:
2 Within the declaration or body of a task unit, the name of the task unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding task type (and thus the name cannot be used as a subtype_mark).
by:
2 Other than in an access_definition, the name of a task unit within the declaration or body of the task unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding task type (and thus the name cannot be used as a subtype_mark).
!corrigendum 9.4(21)
Replace the paragraph:
13 Within the declaration or body of a protected unit, the name of the protected unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding protected type (and thus the name cannot be used as a subtype_mark).
by:
13 Within the declaration or body of a protected unit other than in an access_definition, the name of the protected unit denotes the current instance of the unit (see 8.6), rather than the first subtype of the corresponding protected type (and thus the name cannot be used as a subtype_mark).
!ACATS test
ACATS tests need to be constructed for this rule.
!appendix

****************************************************************

Questions? Ask the ACAA Technical Agent