Version 1.1 of ais/ai-00400.txt

Unformatted version of ais/ai-00400.txt version 1.1
Other versions for file ais/ai-00400.txt

!standard 3.9(7)          05-01-27 AI95-00400/01
!standard 3.9(10)
!standard 11.4(2/2)
!standard 11.4(5)
!standard 11.4(12/2)
!class amendment 05-01-25
!status work item 05-01-25
!status received 05-01-25
!priority High
!difficulty Easy
!subject Wide_ and Wide_Wide_ variants for the subprograms that return the
image of identifiers
!summary
(See proposal.)
!problem
Now that identifiers can use 16- and 32-bit characters, the operations that construct the image of identifiers may end up having to create Wide_ or Wide_Wide_Strings. This was acknowledged by the introduction of attributes Wide_Wide_Image, Wide_Wide_Value, etc. However, there are functions in packages Ada.Tags and Ada.Exceptions which return the image of the (full) name of a tag or an exception. At a minimum, we must specify what these functions do when they encounter an identifier with a character which is not in subtype Character.
Note that this AI is not proposing to introduce Wide_ or Wide_Wide_String variants of the numerous functions that operate on String in the predefined units (e.g., Ada.Text_IO.Open). This would be a much bigger change, and we haven't seen demand for this. What this AI is doing is fixing an inconsistency that was missed when 16- and 32-bit characters were introduced.
!proposal
(See wording.)
!wording
Change 3.9(7) to include the following declarations
function Expanded_Name(T : Tag) return String; function Wide_Expanded_Name(T : Tag) return Wide_String; function Wide_Wide_Expanded_Name(T : Tag) return Wide_Wide_String;
Change 3.9(10) to read:
The function Wide_Wide_Expanded_Name returns the full expanded name of the first subtype of the specific type identified by the tag, in upper case, starting with a root library unit. The result is implementation defined if the type is declared within an unnamed block_statement.
The function Expanded_Name (respectively, Wide_Expanded_Name) returns the same sequence of graphic characters as that defined for Wide_Wide_Expanded_Name, if all the graphic characters are defined in Character (respectively, Wide_Character); otherwise, the sequence of characters is implementation defined, but no shorter than that returned by Wide_Wide_Expanded_Name for the same value of the argument.
Change 11.4(2/2) to include the following declarations:
function Exception_Name(Id : Exception_Id) return String; function Wide_Exception_Name(Id : Exception_Id) return Wide_String; function Wide_Wide_Exception_Name(Id : Exception_Id) return Wide_Wide_String;
Change 11.4(5) to include the following declarations:
function Exception_Name(X : Exception_Occurrence) return String; function Wide_Exception_Name(X : Exception_Occurrence) return Wide_String; function Wide_Wide_Exception_Name(X : Exception_Occurrence) return Wide_Wide_String;
Change 11.4(12/2) to read:
The functions Wide_Wide_Exception_Name return the full expanded name of the exception, in upper case, starting with a root library unit. The returned string has lower bound 1. For an exception declared immediately within package Standard, the defining_identifier is returned. The result is implementation defined if the exception is declared within an unnamed block_statement.
The functions Exception_Name (respectively, Wide_Exception_Name) return the same sequence of graphic characters as that defined for Wide_Wide_Exception_Name, if all the graphic characters are defined in Character (respectively, Wide_Character); otherwise, the sequence of characters is implementation defined, but no shorter than that returned by Wide_Wide_Exception_Name for the same value of the argument.
!discussion
The following approaches were considered:
1 - Don't change the specification of Ada.Tags and Ada.Exceptions, the functions return an implementation-defined string when the full name contains a wide or wide-wide character. Users who take advantage of the extended character set cannot count on any portability in this area.
2 - Change the existing functions to return Wide_Wide_String instead of String. Presumably this is the worst incompatibility, as many existing usages would have to be changed, including code that prints or stores these strings for logging purposes.
3 - Add extra overloads returning Wide_String and Wide_Wide_String. This introduces some incompatibilities, mostly in code that uses these functions in conjunction with string literals.
4 - Add new functions with distinct names. This still introduces incompatibilities, but only in code that has use clauses and declares identifiers that clash, and this is extremely unlikely.
This AI was written for option 4. The wording is then similar to that for the Wide_Wide_ attributes: the semantics is well defined for the function returning Wide_Wide_String, and for the others as long as the full name is only made up of Characters (resp. Wide_Characters). Otherwise, the semantics is implementation defined.
!example
--!corrigendum
!ACATS test
ACATS C-Test(s) should be created to check that these functions exist and work as specified. (This will require Unicode source code for these tests.)
!appendix

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

Questions? Ask the ACAA Technical Agent