Version 1.1 of acs/ac-00069.txt

Unformatted version of acs/ac-00069.txt version 1.1
Other versions for file acs/ac-00069.txt

!standard 12.7(04)          03-08-04 AC95-00069/01
!class confirmation 03-08-04
!status received no action 03-08-04
!status received 03-06-11
!subject Generic formal package referring to enclosing generic
!summary
!appendix

From: Adam Beneschan
Sent: Wednesday, June 11, 2003  6:29 PM

I believe the following two code examples are illegal:

Example 1:

   generic
      type T is private;
   package pak1 is

      generic
         with package new_pak1 is new pak1 (<>);
      package pak2 is
      end pak2;

   end pak1;

Example 2:

   generic
      type T is private;
   package pak1 is
   end pak1;

   generic
      with package new_pak1 is new pak1 (<>);
   package pak1.pak2 is
   end pak1.pak2;

The syntax of the "with package" clause requires that the identifier
following "new" denotes a generic package (12.7(4)).

However, it looks like the identifier "pak1" in the "with package"
clause does not denote a generic package.  By applying 8.6(18), we
find that the use of "pak1" in the "with package" is within the
declarative region of pak1, and thus "denotes the current instance of
the generic unit (rather than the generic unit itself)."  Since "pak1"
denotes the current instance, it denotes a package rather than a
generic package, and thus cannot be used in the "with package"
clause.

Is my analysis correct?  Should these constructs be allowed?

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

From: Gary Dismukes
Sent: Wednesday, June 11, 2003  7:22 PM

Yes, your analysis is correct.  The formal packages are illegal
the same way that recursive instantiations within a generic unit
are illegal (because the name denotes a package not a generic
package).  I don't think these should be allowed, and I'm sure
they would cause fits for compilers (for sure the first case
should be disallowed since the parent generic's specification
isn't even completely defined at the point of the formal package).

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

From: Pascal Leroy
Sent: Thursday, June 12, 2003  3:08 AM

I agree with Gary, especially the part about "fits".

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

Questions? Ask the ACAA Technical Agent