Version 1.1 of ais/ai-00313.txt

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

!standard 8.3 (16)          02-09-27 AI95-00313/01
!standard 8.3 (17)
!class amendment 02-09-27
!status work item 02-09-27
!status received 02-09-20
!priority Low
!difficulty Easy
!subject Self-reference in subprogram access
!summary
The name of an access-to-subprogram type can be used in the declaration of the type.
!problem
It is very inconvinient to write an access-to-subprogram type which takes a parameter of the type itself.
!proposal
Add after 8.3(17):
For an access-to-subprogram type, the declaration is hidden from all visibility only until the reserved keyword access;
!discussion
For example:
type Chaining_Procedure is access procedure (...<other parameters>...; Next_Proc : Chaining_Procedure);
This is illegal by 8.3(16). Declaring Chaining_Procedure as an incomplete type prior to this doesn't help, because of 8.3(19).
The best workaround seems to be to add a new type:
type Chaining_Procedure_2; type Chaining_Procedure is access procedure
(...<other parameters>...; Next_Proc : Chaining_Procedure_2);
type Chaining_Procedure_2 is new Chaining_Procedure;
which requires the use of type conversions between the types.
!examples
!ACATS test
An ACATS C-Test should be created.
!appendix

!topic Self-reference in subprogram access
!reference RM95 8.3(16-18), 3.10
!from Adam Beneschan 09-20-02
!discussion

Is there any reason why this should be illegal?

   type Chaining_Procedure is access procedure
            (...<other parameters>...; Next_Proc : Chaining_Procedure);

This is illegal by 8.3(16) [and declaring Chaining_Procedure as an
incomplete type prior to this doesn't help, because of 8.3(19)].
However, someone may want to do something like this, and there aren't
any implementation problems that I can think of.

(The best workaround I can think of is to add a new type:

   type Chaining_Procedure_2;
   type Chaining_Procedure is access procedure
            (...<other parameters>...; Next_Proc : Chaining_Procedure_2);
   type Chaining_Procedure_2 is new Chaining_Procedure;

which may necessitate a type conversion in some cases.)

Anyway, this may not be a high priority, but it seems harmless to me
to add another exception after 8.3(17) that for an
access-to-subprogram type declaration, the declaration is hidden from
all visibility only until the reserved word "access".

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

From: Randy Brukardt
Sent: Friday, September 27, 2002  3:10 PM

I do agree its harmless, but even so, its additional work. (Figuring out how
to change 'hidden from all visibility' is non-trivial in Janus/Ada, at
least). Given that, I'd like to know if anyone has run into this problem in
practice. If not, perhaps it is not worth the effort to change even if it
would be relatively easy.

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

Questions? Ask the ACAA Technical Agent