AI22-0116-1
!standard C.5(7/4) 25-04-24 AI22-0116-1/04
!class Binding Interpretation 24-09-07
!status Amendment 1-2022 24-11-01
!status WG9 Approved 25-07-18
!status ARG Approved 15-0-0 24-10-31
!status work item 24-09-07
!status received 24-07-19
!submitter Stephen Baird
!priority Low
!difficulty Easy
!qualifier Error
!subject Discard_Names and Put_Image
When Discard_Names is applied to an enumeration type, it is the default version of Put_Image that is implementation defined, not the attribute Wide_Wide_Image.
In Ada 2022, Wide_Wide_Image is defined in terms of Put_Image by 4.10(30.2/5). However, C.5(7/4) says in part:
If the aspect Discard_Names is True for an enumeration type, then the semantics of the Wide_Wide_Image and Wide_Wide_Value attributes are implementation defined for that type.
If a user-defined Put_Image is defined for a type with aspect Discard_Names, one would still expect Wide_Wide_Image to work as defined.
(See Summary.)
Modify C.5(7/4):
If the aspect Discard_Names is True for an enumeration type, then the semantics of the {default implementation of the Put_Image attribute is implementation defined for that type[Redundant: ; the semantics of Image, Wide_Image, and Wide_Wide_Image are still defined in terms of Put_Image]. Similarly, the semantics of the}[Wide_Wide_Image and] Wide_Wide_Value attribute[s are]{is} implementation defined for {such a}[that] type[Redundant: ; the semantics of [Image, Wide_Image, ]Value, and Wide_Value are still defined in terms of [Wide_Wide_Image and ]Wide_Wide_Value]. In addition, the semantics of Text_IO.Enumeration_IO are implementation defined. If the aspect Discard_Names is True for a tagged type, then the semantics of the Tags.Wide_Wide_Expanded_Name function are implementation defined for that type[Redundant: ; the semantics of Tags.Expanded_Name and Tags.Wide_Expanded_Name are still defined in terms of Tags.Wide_Wide_Expanded_Name]. If the aspect Discard_Names is True for an exception, then the semantics of the Exceptions.Wide_Wide_Exception_Name function are implementation defined for that exception[Redundant: ; the semantics of Exceptions.Exception_Name and Exceptions.Wide_Exception_Name are still defined in terms of Exceptions.Wide_Wide_Exception_Name].
Modify AARM C.5(7.c/4):
{Aspect Discard_Names has no effect on S'Wide_Wide_Image for any type for which aspect Put_Image is specified. The semantics of S'Wide_Wide_Image is as specified in 4.10 for any subtype of such a type.}
The semantics of [S'Wide_Wide_Image and ]S'Wide_Wide_Value {is}[are] implementation defined for any subtype of an enumeration type for which the aspect is True. (The {aspect}[pragma], if used, actually {applies to}[names the] first subtype, of course.)
When Wide_Wide_Image was redefined in terms of Put_Image, it is clear that the wording of C.5 should have been adjusted. But that did not happen.
It is clear that aspect Discard_Names should only apply to the default implementation of Put_Image for an enumeration type, as described in 4.10(12/5). That implementation becomes
implementation defined if Discard_Names is True for an enumeration type. The aspect should not affect a specified implementation of Put_Image, and in particular all of the Image attributes should work as expected in that case. Aspect Discard_Names can still be useful for such a type, if none of the Value attributes are needed, the overhead of supporting them can be avoided.
@drepl
If the aspect Discard_Names is True for an enumeration type, then the semantics of the Wide_Wide_Image and Wide_Wide_Value attributes are implementation defined for that
type; the semantics of Image, Wide_Image, Value, and Wide_Value are still defined in terms of Wide_Wide_Image and Wide_Wide_Value. In addition, the semantics of Text_IO.Enumeration_IO are implementation defined. If the aspect Discard_Names is True for a tagged type, then the semantics of the Tags.Wide_Wide_Expanded_Name function are implementation defined for that type; the semantics of Tags.Expanded_Name and Tags.Wide_Expanded_Name are still defined in terms of Tags.Wide_Wide_Expanded_Name. If the aspect Discard_Names is True for an exception, then the semantics of the Exceptions.Wide_Wide_Exception_Name function are implementation defined for that exception; the semantics of Exceptions.Exception_Name and Exceptions.Wide_Exception_Name are still defined in terms of Exceptions.Wide_Wide_Exception_Name.
@dby
If the aspect Discard_Names is True for an enumeration type, then the semantics of the default implementation of the Put_Image attribute is implementation defined for that type; the semantics of Image, Wide_Image, and Wide_Wide_Image are still defined in terms of Put_Image. Similarly, the semantics of the Wide_Wide_Value attribute is implementation defined for such a type; the semantics of Value, and Wide_Value are still defined in terms of Wide_Wide_Value. In addition, the semantics of Text_IO.Enumeration_IO are implementation defined. If the aspect Discard_Names is True for a tagged type, then the semantics of the Tags.Wide_Wide_Expanded_Name function are implementation defined for that type; the semantics of Tags.Expanded_Name and Tags.Wide_Expanded_Name are still defined in terms of Tags.Wide_Wide_Expanded_Name. If the aspect Discard_Names is True for an exception,
then the semantics of the Exceptions.Wide_Wide_Exception_Name function are implementation defined for that exception; the semantics of Exceptions.Exception_Name and Exceptions.Wide_Exception_Name are still defined in terms of Exceptions.Wide_Wide_Exception_Name.
An ACATS C-Test should be constructed to check that for an enumeration type that
has both a Put_Image aspect specification and Discard_Names => True, the Image
attributes work as expected using the specified Put_Image.
From: Stephen Baird
Sent: Friday, July 19, 2024 5:21 PM [Privately]
Suppose we have an enumeration type that has both a Put_Image aspect specification and Discard_Names => True.
Does the current wording in C.5 correctly handle this case?
In particular,
If the aspect Discard_Names is True for an enumeration type, then the
semantics of the Wide_Wide_Image and Wide_Wide_Value attributes are
implementation defined for that type.
I have no problem with this wording as it applies to Wide_Wide_Value.
But I think there would be nothing implementation-defined about the semantics of Wide_Wide_Image if the enumeration type has a specified Put_Image procedure.
What do you think? Perhaps a TBH note?
From: Randy Brukardt
Sent: Friday, July 19, 2024 5:32 PM [Privately]
Yes, looks like an omission. Or perhaps an error, since Wide_Wide_Image is defined in terms of Put_Image now, right? So there is nothing implementation-defined about it in any case, it is the default implementation of Put_Image that might be implementation-defined. It should say "the semantics of the default implementation of Put_Image and of the Wide_Wide_Value attributes are implementation-defined".
From: Stephen Baird
Sent: Friday, July 19, 2024 5:38 PM [Privately]
So maybe what becomes implementation-dependent as a result of a DIscard_Names specification is the default implementation of Put_Image for the type in question. If a Put_Image aspect spec is given, then it goes without saying that nobody cares about what the default implementation would have done.
From: Stephen Baird
Sent: Friday, July 19, 2024 5:40 PM [Privately]
Yes, I just repeated your proposal back to you.