Version 1.1 of acs/ac-00160.txt

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

!standard 3.10.2(24)          08-05-10 AC95-00160/01
!class confirmation 08-05-10
!status received no action 08-05-10
!status received 08-03-05
!subject An expanded name in a protected body is an internal call

!topic Dereference of 'Access attribute
!reference 3.10.2(24), 4.1(8)
!from Adam Beneschan 08-03-05

In this construct:


What is the type of Z'Access?  The rules don't give an answer for this.
3.10.2(24) says that the type of an 'Access attribute (on an object) is
determined by the expected type; 4.1(8) says that the expected type for a
dereference (.all) is "any access type".

The reason it makes a difference is for determining the accessibility level.
3.10.2(15) says that "The accessibility level of a view of an object ... denoted
by a dereference of an access value is the same as that of the access type". But
if we don't know what the access type is, we can't know what the accessibility
level is.

This came up when I was asked to look at code like this:

   type Int_Access is access all Integer;

   function F2 (X2 : access Integer) return Int_Access is
      return X2.all'Access.all'Access;
   end F2;

   function F3 (X2 : access Integer) return Int_Access is
      return X2.all'Access.all'Access.all'Access;
   end F3;

Granted, this is pathological, not to mention silly---nobody would write code
like this.  But I couldn't determine whether this code is supposed to be
rejected at compile time, raise Program_Error regardless of the anonymous access
function parameter, or raise Program_Error only if the access parameter has
deeper accessibility than Int_Access.


From: Tucker Taft
Date: Wednesday, March  5, 2008  7:54 PM

The construct 'Access.all is not legal.
On the other hand, .all'Access is legal, and is a useful way to convert to
another access type in some circumstances.

'Access.all is illegal based on 3.10.2(2) which requires the expected type for
'Access to be a "single access type such that..." and 8.6(27) which specifically
disallows expected types that allow for any type in a class when a single type
is required, plus 4.1(8) which says the expected type is "any access type."


From: Adam Beneschan
Date: Thursday, March  6, 2008  10:05 AM

Grrrr... I usually catch those things, but I missed this one.
Thanks---that clears everything up.


Questions? Ask the ACAA Technical Agent