Version 1.2 of ai05s/ai05-0105-1.txt

Unformatted version of ai05s/ai05-0105-1.txt version 1.2
Other versions for file ai05s/ai05-0105-1.txt

!standard 8.5.1(3/2)          08-07-03 AI05-0105-1/02
!class confirmation 08-06-15
!status ARG Approved 7-0-1 08-06-21
!status work item 08-06-15
!status received 08-05-16
!priority Low
!difficulty Easy
!subject Resolution of renames uses anonymousness
!summary
An object renaming that specifies an access_definition (an anonymous access type) resolves to an object that has an anonymous access type.
!question
Consider the following case:
type Acc_Int is access all Integer;
function Foo return Acc_Int;
function Foo return access Integer;
Obj : access Integer renames Foo; -- OK.
The rules as written say this is OK. Resolution requires that the name resolve to an anonymous access type, and there is only one interpretation of Foo that fits that.
However, we usually use as little information as possible about types (we don't depend on general vs. pool-specific for instance when resolving 'Access). Should we be using anonymity here? (Yes.)
!response
Such a rename can be used to select an anonymous access returning function from a named one. Since qualification is not available for anonymous types, it's not clear how else this could be accomplished.
Moreover, we are treating all anonymous-access-to-T as a single type for resolution purposes -- but that clearly is distinct from named access-to-T.
!ACATS Test
An ACATS C-Test should be created to test the idiom of renaming to select a function. It is suggested that the test try two functions returning record types with similarly named components that differ just by named versus anonymous access.
!appendix

From: Randy Brukardt
Sent: Friday, May 16, 2008 10:02 PM

I'm looking at the tests needed for 8.5.1 (object renaming), and I'm stumped
as to how the name resolution rules should be tested. So far as I can tell,
there isn't any significant discussion of why we adopted the particular rules
we have. Usually, we use as little as possible for resolution, and that isn't
quite the case for 8.5.1.

Consider the following case:

     type Acc_Int is access all Integer; 

     function Foo return Acc_Int;

     function Foo return access Integer;

     Obj : access Integer renames Foo; -- OK.

The rules as written say this is OK. Resolution requires that the name resolve
to an *anonymous* access type, and there is only one interpretation of Foo that
fits that. This seems like something that should be tested, so test priority 7 (out of 10).

But wait: this seems to be an amazingly dumb thing to do. It would be hard to
call this Foo because it would almost always be ambiguous, and it doesn't
seem to have any value to be declared both ways. I don't want to push vendors
into working on minutea, so test priority 3.

On the third hand, this could happen to an unfortunate programmer through
collisions from use clauses and the like. Since qualification is not available
for the anonynous access returning function (because the type has no name, duh!),
it would seem to be pretty hard to select it. But the above rename works,
and the result of that can then be used to avoid problems. So it appears that
this rule is possibly the only way out of a sticky situation, in which case this
unusual case should be tested throughly (so it works when needed, which is likely
to be rarely). That makes the test priority 8 or even 9.

So now I'm totally confused. Was it really our intent that a rename like the
above be used in place of qualification? If so, authors need to mention it as
a technique, and it should be tested so it works in the unlikely case that
it is needed. If not, then testing is much less important, as it seems pretty
unlikely that the situation would come up.

Thoughts?

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

From: Tucker Taft
Sent: Saturday, May 17, 2008  6:57 AM

Overload resolution is normally based on types.  We are merely treating
all of the anonymous access types that designate the same type as
effectively a single distinct type for the purposes of renaming.
That doesn't seem unreasonable.  I believe we do roughly the same thing
for renaming of subprograms, so it would seem weird if "anonymous-ness"
wasn't part of the overload resolution for object renaming.

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

From: Edmond Schonberg
Sent: Saturday, May 17, 2008  4:40 PM

I lean towards pathology. The two definitions of Foo in the same scope 
are sufficiently suspicious that GNAT actually warns about it:

Compiling: ren.ads (source file time stamp: 2008-05-17 21:32:43)

      6.      function Foo return access Integer;
                       |
         >>> warning: calls to "Foo" may be ambiguous

On the other hand, GNAT also considers the subsequent call to be
ambiguous (following the warning :-)!  because we overlooked the last part
of the first sentence in 8.5.1 (3/2). It's easy enough to apply, but I
see no reason to encourage this idiom. I guess whoever is responsible for
that sentence thinks otherwise :-)!

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


Questions? Ask the ACAA Technical Agent