Version 1.2 of acs/ac-00163.txt

Unformatted version of acs/ac-00163.txt version 1.2
Other versions for file acs/ac-00163.txt

!standard 10.1.2(19)          08-05-10 AC95-00163/01
!standard 10.1.2(20)
!standard 10.1.2(21)
!standard 10.1.2(22)
!class confirmation 08-05-10
!status received no action 08-05-10
!status received 08-04-28
!subject Useless USE TYPE's in "limited with" cases
!summary
!appendix

!topic Useless USE TYPE's in "limited with" cases
!reference RM05 10.1.2(19-22)
!from Adam Beneschan 08-04-28
!discussion


This seems to be a somewhat bizarre consequence of the rules as currently
written, although I'm not sure it's a serious problem:

Assuming Pak1 and Pak1.Pak2 have been declared, and Pak1 declares a type T: This
is illegal by 10.1.2(19,22):

-- Example 1
   limited with Pak1;
   limited with Pak1.Pak2;
   use type Pak1.T;
   package Pak3 is ...

But this seems to be legal:

-- Example 2
   limited with Pak1.Pak2;
   use type Pak1.T;
   package Pak3 is ...

I believe it's legal because 10.1.2(19-22) don't apply.  10.1.2(19) applies only
to packages *named* in a limited with, and Pak1 is mentioned but not named.
Pak1.Pak2 is named but T is of course not in its declarative region.

The "use type" can't have any effect, however, because from what I can tell,
only the limited view of Pak1 will be visible, and limited views don't include
any subprograms, so the "use type" cannot make any operators visible.

Of course, we can't just changed "named" do "mentioned" in 10.1.2(19) because we
want this to be legal:

-- Example 3
   with Pak1;
   limited with Pak1.Pak2;
   use type Pak1.T;
   package Pak3 is ...

and now since the full view of Pak1 is visible, T's operators will be visible.  Similarly, this makes sense if Pak4 had a "with Pak1" on it:

-- Example 4
   limited with Pak1.Pak2;
   use type Pak1.T;
   package Pak4.Pak3 is ...

I haven't been able to find a case where there is a real contradiction or an
ambiguity or anything, so I think the worst case is that if this is allowed:

-- Example 2
   limited with Pak1.Pak2;
   use type Pak1.T;
   package Pak3 is ...

the "use type" will be noise.  But it could be confusing, and there are other
cases involving "limited with" that have been made illegal because they would
have no effect and could be confusing.

Would it be desirable, perhaps, to add a rule that "use type" is illegal if the
type is immediately declared in a package for which only the limited view is
available (which would automatically mean that no operations of the type are
visible)?  I dunno... what do the rest of you think?  Or did I miss a rule that
would make Example 2 illegal?  I've searched but haven't been able to find one.

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

From: Randy Brukardt
Date: Monday, April 28, 2008  8:47 PM

> I believe it's legal because 10.1.2(19-22) don't apply.  10.1.2(19)
> applies only to packages *named* in a limited with, and Pak1 is
> mentioned but not named.  Pak1.Pak2 is named but T is of course not in
> its declarative region.

Yes, I think you are right that there is a problem. But I don't think it is
limited to use type. In particular:

    limited with Pak1.Pak2;
    use Pak1.Nested_Package;
    package Pak3 is ...

would seem to have the same problem. (Presuming there is a package actually
nested in Pak1 called Nested_Package.)

...
> Of course, we can't just changed "named" do "mentioned" in 10.1.2(19)
> because we want this to be legal:
>
> -- Example 3
>    with Pak1;
>    limited with Pak1.Pak2;
>    use type Pak1.T;
>    package Pak3 is ...
>
> and now since the full view of Pak1 is visible, T's operators will be
> visible.

Yup.

...
> Would it be desirable, perhaps, to add a rule that "use type" is
> illegal if the type is immediately declared in a package for which
> only the limited view is available (which would automatically mean
> that no operations of the type are visible)?  I dunno... what do the
> rest of you think?  Or did I miss a rule that would make Example 2
> illegal?  I've searched but haven't been able to find one.

Surely we don't want any rules that apply only to "use type", especially as
package use clauses can have the same problem.

Oh, wait a minute. My example is illegal by 8.4(5/2). And your example is
illegal by 3.10.1(9.4/2): "No other uses of a name that denotes an incomplete
view of a type are allowed." That surely included use type clauses: they're not
included in any of the lists of bullets previously given in 3.10.1.

So your original example is illegal because the use type clause is illegal; and
there is no further problem.

P.S. I think we may need to rename this list to "Adam-Comment"! ;-)

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


Questions? Ask the ACAA Technical Agent