Version 1.1 of acs/ac-00222.txt

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

!standard 13.14(8)          12-01-21 AC95-00222/00
!class Amendment 12-01-21
!status received no action 11-01-21
!status received 11-07-01
!subject Function bodies for enumeration literals
!summary
!appendix

!topic Freezing rules in pragmas
!reference 13.14(8)
!from Adam Beneschan 11-07-01
!discussion

This is extracted from real code:

    package Pack1 is
        type Object (Stack_Size : Natural) is limited private;
    private
        task type Worker (Parent : access Object) is
            pragma Storage_Size (Parent.Stack_Size);
            ...
        end Worker;
        type Object (Stack_Size : Natural) is record ... end record;
    end Pack1;

Is the Storage_Size pragma legal?  It doesn't seem like it should be in Ada 95
or Ada 2005, since a non-static expression causes freezing where it occurs, with
certain exceptions, and a Storage_Size pragma doesn't appear to be one of the
exceptions; this would freeze the definition of Object before it's completed.

In Ada 2012, the situation is curious, because the Storage_Size pragma is
obsolescent and being replaced by an aspect specification; also, 13.14(8) now
says that expressions in aspect specifications don't cause freezing, but it
doesn't say anything similar about the equivalent pragmas.  So it would seem
that

    task type Worker (Parent : access Object)
       with Storage_Size => Parent.Stack_Size is ...

is clearly legal, but using the obsolescent pragma form that's supposed to be
equivalent still isn't legal.

Should this be changed (e.g. should 13.14(8) include pragmas that are
"alternative" to aspect specifications, in the wording of J.15, in the list of
exceptions---or should the exceptions include all representational pragmas, or
something along those lines)?

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

From: Randy Brukardt
Sent: Friday, July 1, 2011  7:06 PM

...
> Is the Storage_Size pragma legal?  It doesn't seem like it should be
> in Ada 95 or Ada 2005, since a non-static expression causes freezing
> where it occurs, with certain exceptions, and a Storage_Size pragma
> doesn't appear to be one of the exceptions; this would freeze the
> definition of Object before it's completed.

I agree, this does not appear to be legal.

> In Ada 2012, the situation is curious, because the Storage_Size pragma
> is obsolescent and being replaced by an aspect specification; also,
> 13.14(8) now says that expressions in aspect specifications don't
> cause freezing, but it doesn't say anything similar about the
> equivalent pragmas.  So it would seem that
>
>     task type Worker (Parent : access Object)
>        with Storage_Size => Parent.Stack_Size is ...
>
> is clearly legal, but using the obsolescent pragma form that's
> supposed to be equivalent still isn't legal.

The pragmas aren't exactly equivalent to the aspects (and by now, you should
know that nothing is ever *exactly* equivalent to something else, we try hard to
avoid using wording like that because it always turns out to be a lie). All the
wording says is that the pragma sets the aspect. That does not mean "equivalent"
in any other sense.

> Should this be changed (e.g. should 13.14(8) include pragmas that are
> "alternative" to aspect specifications, in the wording of J.15, in the
> list of exceptions---or should the exceptions include all
> representational pragmas, or something along those lines)?

IMHO, no. These pragmas were a horrible mistake in the first place (one that I
fought hard against in Ada 9x, preferring some sort of
attribute_definition_clause in their place, but I lost that battle). I'd be
happy if you could prove that all uses of them caused freezing errors. ;-)
Seriously, we try very hard not to mess up the core language to support
obsolescent features. I don't see any reason or value to changing the way an
obsolescent feature works just because a new feature allows more. (That's
typical of new features, after all.) In the unlikely case that someone ran into
this problem, writing things the recommended way would fix the problem. That
doesn't seem that bad.

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

Questions? Ask the ACAA Technical Agent