Version 1.1 of ais/ai-00042.txt

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

!standard 03.10.01 (09)          96-11-16 AI95-00042/02
!class confirmation 95-06-25
!status WG9 approved 96-12-07
!status ARG Approved 10-0-0 96-10-07
!status work item 96-04-19
!status received 95-06-25
!priority Low
!difficulty Easy
!subject use of incomplete types
!summary 95-06-25
The 'Class attribute may be applied to an incomplete type declared in a private part, even if the full type is declared in the package body. The full type must be a tagged type.
!question 96-04-19
If an incomplete type is declared in a private part, the corresponding full type may appear in the package body. Is it the intent that 'Class is allowed for such an incomplete type? (Yes.) What if the full type is untagged? (Then it's illegal.)
!response 95-06-25
3.10.1(9) allows 'Class for any incomplete type, so long as the full type is tagged.
!appendix

!section 3.10.1(9)
!subject use of incomplete types
!reference AARM-3.10.1(9);6.0
!from Jesper Joergensen 95-04-12
!reference as: 95-5123.a Jesper Joergensen 95-4-12>>
!discussion

The allowed uses of a subtype_mark denoting an incomplete type in a 'class
attribute are not quite clear for the case where an incomplete type is declared
in the private part of a package and the corresponding full type declaration
occurs in the package body. Consider:


   package P is
   private
      type T;
      procedure Q( X : T'Class );   -- legal ?
   end P;


   package body P is
      type T is tagged...
      procedure Q( X : T'Class ) is
      begin
         null;
      end Q;
   end P;


If we take 3.10.1(9) literally, the above is legal (because the term "library
unit" rather than "compilation unit" is used), but was that really the
intention?

If it was the intention, I presume that the compiler should reject the package
body if the full type declaration of T is not tagged?

BTW., I think you should add this allowed use of 'Class in Annex K.


/Jesper


P.S. I sent a comment on overriding of subprograms (95-5118.a) that I did not
get any answer to. In particular, I would like to know the answer to the very
last question of that comment.

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

!section 3.10.1(9)
!subject use of incomplete types
!reference AARM-3.10.1(9);6.0
!reference 95-5123.a Jesper Joergensen 95-04-12
!from Tucker Taft 95-04-12
!reference as: 95-5125.a Tucker Taft 95-4-12>>
!discussion

> The allowed uses of a subtype_mark denoting an incomplete type in a 'class
> attribute are not quite clear for the case where an incomplete type is declared
> in the private part of a package and the corresponding full type declaration
> occurs in the package body. Consider:
>
>
>    package P is
>    private
>       type T;
>       procedure Q( X : T'Class );   -- legal ?

Yes, this is legal, per 3.10.1(9).

>    end P;
>
>
>    package body P is
>       type T is tagged...
>       procedure Q( X : T'Class ) is
>       begin
>          null;
>       end Q;
>    end P;
>
>
> If we take 3.10.1(9) literally, the above is legal (because the term "library
> unit" rather than "compilation unit" is used), but was that really the
> intention?

Yes, that was the intent.

> If it was the intention, I presume that the compiler should reject the package
> body if the full type declaration of T is not tagged?

Yes, a use of 'Class on an incomplete type forces the full type
to be tagged.  As explained in 3.10.1(9.a), 3.10.1(9) requires
the reference to be in the same library unit so that a reference
in a child cannot force the full type to be tagged, but a use of 'Class
in a package spec can force the full declaration in the package body to
be tagged.

> BTW., I think you should add this allowed use of 'Class in Annex K.

Agreed.

> /Jesper
>
>
> P.S. I sent a comment on overriding of subprograms (95-5118.a) that I did not
> get any answer to. In particular, I would like to know the answer to the very
> last question of that comment.

Unfortunately, the Ada 9X Mapping/Revision funds are nearing exhaustion,
so we cannot guarantee rapid response to all questions posted here.
Once the reconsitituted ARG is created, I would expect them to take
over answering questions.  However, in the interim, please have patience...

Also, as a favor, please include a "Subject:" line in all mail to
the ada-comment/ada9x-mrt mailing list.

-Tuck

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

Questions? Ask the ACAA Technical Agent