Version 1.4 of ai05s/ai05-0108-1.txt

Unformatted version of ai05s/ai05-0108-1.txt version 1.4
Other versions for file ai05s/ai05-0108-1.txt

!standard 10.1.1(12.3/2)          08-11-18 AI05-0108-1/02
!class binding interpretation 08-07-12
!status Amendment 201Z 08-11-26
!status ARG Approved 8-0-0 08-10-31
!status work item 08-07-12
!status received 08-05-30
!priority Low
!difficulty Easy
!qualifier Omission
!subject The incomplete view from a limited view does not have a discriminant part
!summary
The incomplete view of a type found in a limited view of a package does not have a discriminant part even if some view of the type does have a discriminant part.
!question
10.1.1(12.3) discusses what the limited view of a package looks like, with respect to types declared in that package:
For each type_declaration in the visible part, an incomplete view of the type; if the type_declaration is tagged, then the view is a tagged incomplete view.
Does this incomplete view include a discriminant part, if the type has one? (No.)
Since incomplete views (declared by incomplete_type_declarations) may have discriminant parts, the above language doesn't seem to exclude the possibility of a discriminant part, but it also doesn't imply that a discriminant part is present.
So, is the following legal? (No.)
package Pak1 is type T1 (Disc : Integer) is record ... end record; end Pak1;
limited with Pak1; package Pak2 is type Acc_T1 is access Pak1.T1(4); -- Error. end Pak2;
!recommendation
(See summary.)
!wording
Change 10.1.1(12.3/2):
* For each type_declaration in the visible part, an incomplete
view of the type {with no discriminant_part}; if the type_declaration is tagged, then the view is a tagged incomplete view.
AARM Ramification: The incomplete view of a type does not have a discriminant_part even if the the type_declaration does have one. This is necessary because semantic analysis (and the associated dependence on with_clauses) would be necessary to determine the types of the discriminants.
!discussion
One could argue that since the wording says nothing about discriminant_parts, one is not present. (Indeed, the author initially did just that.) However, one could easily imagine that such a part is present; it's just not clear.
However, it should be clear from the model of limited views that such discriminant_parts cannot be present. A limited view is intended to be creatable only with syntactic analysis: in particular, no name resolution is required.
The example in the question clearly violates that: without semantic analysis, the meaning of the name "Integer" is not known. Moreover, the model is that all types are incomplete. That would prevent giving useful discriminant constraints anyway: the value "4" is not a value of any incomplete view.
Thus the best thing to do is to add wording to clarify the intent.
!corrigendum 10.1.1(12.3/2)
Replace the paragraph:
by:
!ACATS Test
An ACATS B-Test should be created to check that this is illegal. (Probably just add cases to the existing tests.)
!appendix

!topic RM doesn't say whether incomplete views have discriminants
!reference 10.1.1(12.3)
!from Adam Beneschan 08-05-30
!discussion


10.1.1(12.3) discusses what the limited view of a package looks like, with
respect to types declared in that package:

    For each type_declaration in the visible part, an incomplete view
    of the type; if the type_declaration is tagged, then the view is a
    tagged incomplete view.

However, nothing says whether the incomplete view includes a discriminant part
or not, if the type has one.  Since incomplete views (declared by
incomplete_type_declarations) may have discriminant parts, I cannot see how
the above language excludes the possibility of a discriminant part, but it
also doesn't imply that a discriminant part is present.  So this seems
like a serious omission in the RM.  In particular, I can't tell whether this
is legal:

    package Pak1 is
       type T1 (Disc : Integer) is record ... end record;
    end Pak1;

    limited with Pak1;
    package Pak2 is
       type Acc_T1 is access Pak1.T1(4);
    end Pak2;

Skimming through AI95-217-6, it appears that the intent was that discriminant
parts were not intended to be included on types in limited views of packages
(unless this got changed later by AI-326, or unless I missed something in
AI95-217).  But it appears that the language that would say so didn't make it
into the RM.

I think 10.1.1(12.3) needs to say something one way or the other.

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



Questions? Ask the ACAA Technical Agent