Version 1.1 of acs/ac-00229.txt

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

!standard C.5(7)          12-02-15 AC95-00229/00
!class confirmation 12-02-15
!status received no action 12-02-15
!status received 11-11-08
!subject Value of Width attribute for a type with aspect Discard_Names
!summary
!appendix

From: Robert Dewar
Sent: Tuesday, November  8, 2011  9:53 AM

The RM seems to say that you should be able to do Width on a dynamic subtype of
an enumeration type for which Discard_Names is in effect.

Is this really intended, it is a huge implementation burden obviously!

GNAT does not handle this right. With some considerable effort we could provide
an outrageous implementation, e.g. duplicating the whole table every time such
an attribute occurs (horrible, but no real program will have this, and there
isn't even any ACATS test for this).

We noticed this with GNAT trying to run as many as possible ACATS tests in a
limited environment which included Discard_Names.

Perhaps this can be defined as a pathology.

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

From: Randy Brukardt
Sent: Tuesday, November  8, 2011  11:19 AM

> The RM seems to say that you should be able to do Width on a dynamic
> subtype of an enumeration type for which Discard_Names is in effect.
>
> Is this really intended, it is a huge implementation burden obviously!

It seems to have been intended by the original authors of the standard, because
there is an AARM note (C.5(7.b)) that mentions Width. It says that Width is
"still defined in terms of Image." The semantics of the language say that Image
is implementation-defined in this case, so that makes the result of Width
implementation-defined as well.

> GNAT does not handle this right. With some considerable effort we
> could provide an outrageous implementation, e.g.
> duplicating the whole table every time such an attribute occurs
> (horrible, but no real program will have this, and there isn't even
> any ACATS test for this).

I don't understand this. If Image is used on a type that has the Discard_Names
aspect (it's easier to talk about this than the pragma :-), the result is
implementation-defined. Janus/Ada raises Program_Error on such a use, but I also
could imagine returning the image of 'Pos or something like that. In either of
these cases, the value of 'Width is easy to calculate without "using the whole
table", because there is no table used for 'Image. Dynamic Width is indeed a
pain to implement, but this doesn't seem particularly difficult to do (and since
no one is going to use it, no one cares how much code it uses).

> We noticed this with GNAT trying to run as many as possible ACATS
> tests in a limited environment which included Discard_Names.
>
> Perhaps this can be defined as a pathology.

I suspect that you are using the wrong definition for 'Width -- it returns the
width based on what 'Image actually will return for a particular type, not on
what it would return if Discard_Names was not true. I think this is obvious
(because the interpretation that you seem to be using violates the Dewar rule,
and the one I'm using does not), but if you think that this is unclear I can
create a quick Ramification AI to clarify.

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

From: Robert Dewar
Sent: Tuesday, November  8, 2011  11:35 AM

>> The RM seems to say that you should be able to do Width on a dynamic
>> subtype of an enumeration type for which Discard_Names is in effect.
>>
>> Is this really intended, it is a huge implementation burden obviously!
>
> It seems to have been intended by the original authors of the
> standard, because there is an AARM note (C.5(7.b)) that mentions
> Image. It says that Width is "still defined in terms of Image." The
> semantics of the language say that Image is implementation-defined in
> this case, so that makes the result of Width implementation-defined as well.

OK, but this is rather round about I must say! And the note is not in the RM,

> I don't understand this. If Image is used on a type that has the
> Discard_Names aspect (it's easier to talk about this than the pragma
> :-), the result is implementation-defined. Janus/Ada raises
> Program_Error on such a use, but I also could imagine returning the
> image of 'Pos or something like that. In either of these cases, the
> value of 'Width is easy to calculate without "using the whole table",
> because there is no table used for 'Image. Dynamic Width is indeed a
> pain to implement, but this doesn't seem particularly difficult to do
> (and since no one is going to use it, no one cares how much code it uses).

> I suspect that you are using the wrong definition for 'Width -- it
> returns the width based on what 'Image actually will return for a
> particular type, not on what it would return if Discard_Names was not
> true. I think this is obvious (because the interpretation that you
> seem to be using violates the Dewar rule, and the one I'm using does
> not), but if you think that this is unclear I can create a quick Ramification AI to clarify.

Well probably not worth the effort of an AI, I will fix GNAT to do things right
:-)

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


Questions? Ask the ACAA Technical Agent