!standard 8.6(17) 04-10-12 AI95-00382/02 !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 !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 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. !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. 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; !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 of a parameter 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. !discussion See proposal. !example --!corrigendum !ACATS test ACATS tests need to be constructed for this rule. !appendix ****************************************************************