CVS difference for ais/ai-00241.txt

Differences between 1.2 and version 1.3
Log of other versions for file ais/ai-00241.txt

--- ais/ai-00241.txt	2000/10/06 22:00:51	1.2
+++ ais/ai-00241.txt	2000/12/11 20:20:11	1.3
@@ -1,5 +1,6 @@
-!standard 11.4.1      (3)                        00-10-04  AI95-00241/01
-!class amendment 00-10-04
+!standard 11.4.1      (3)                    00-12-11  AI95-00241/02
+!class binding interpretation 00-11-19
+!status ARG Approved 9-0-1  00-11-19
 !status work item 00-10-04
 !status received 00-10-04
 !priority Medium
@@ -8,45 +9,74 @@
 
 !summary
 
-Function Is_Null_Occurrence is added to Ada.Exceptions.
+The function Exception_Identity applied to Null_Occurrence returns
+Null_Id which can then be tested using the equality operation.
 
-!problem
+!question
 
 Ada.Exceptions exports the constant Null_Occurrence, but doesn't
 provide any way to test whether a given exception occurrence is
-Null_Occurrence (type Exception_Occurrence is limited).
+Null_Occurrence (type Exception_Occurrence is limited). Is this
+intended? (No.)
 
 !proposal
 
-We propose that a function should be added to Ada.Exceptions that
-would allow testing whether an exception occurrence is Null_Occurrence.
+The call Exception_Identity(X) where X has the value Null_Occurrence
+should not raise Constraint_Error but return the value of Null_Id which
+can then be tested against Null_Id using the equality operation.
 
 !wording
-
-Add the following to Ada.Exceptions (11.4.1(3)):
 
-  function Is_Null_Occurrence (X : Exception_Occurrence) return Boolean;
+Replace 11.4.1(14) by
 
-Add the following after 11.4.1(7):
+  Raise_Exception and Reraise_Occurrence have no effect in the case
+  of Null_Id or Null_Occurrence. Exception_Name raises Constraint_Error
+  for a Null_Id. Exception_Message, Exception_Name, and Exception_Information
+  raise Constraint_Error for a Null_Occurrence. Exception_Identity applied
+  to Null_Occurrence returns Null_Id.
 
-  Is_Null_Occurrence yields True if the argument is Null_Occurrence, and False
-  otherwise.
-
-!example
+!discussion
 
+When logging information, an application probably will use
+Null_Occurrence to represent the absence of an exception.
 
-!discussion
+When displaying the log, it is necessary to determine whether a
+particular occurrence is Null_Occurrence, or an occurrence
+containing information about an exception.
+
+Currently, it is difficult to test for Null_Occurrence because,
+being of a limited type, it is not possible to compare with the
+constant Null_Occurrence. Moreover, the function Exception_Identity
+applied to Null_Occurrence raises Constraint_Error. An exception
+handler can be used to detect this but it is awkward, does not
+reflect that this is a normal case, and potentially can mask other
+errors.
+
+Two alternatives were considered. One was to add a function
+Is_Null_Occurrence and the other was to define Exception_Identity to
+return Null_Id when applied to Null_Occurrence rather than raise
+Constraint_Error.
+
+The second approach was taken because it avoids adding a further
+function and moreover it seems unnatural that
+Exception_Id(Null_Occurrence) should raise Constraint_Error.
+
+
+An instance of Null_Occurrence can be tested for as in the following:
+
+procedure Process_Exception(X: Exception_Occurrence) is
+begin
+   if Exception_Identity(X) = Null_Id then
+      -- process the case of a Null_Occurrence
+   else
+      -- process other exception occurrences
+   end if;
+end;
 
-When logging information, an application probably will use Null_Occurrence to
-represent the absence of an exception.
+!ACATS test
 
-When displaying the log, it is necessary to determine whether a particular
-occurrence is Null_Occurrence, or an occurrence containing information about an
-exception.
-
-A Constraint_Error handler can be used for this purpose, but it is awkward,
-does not reflect the fact that this is a normal case, and potentially can mask
-other errors.
+Add a test case to CB41004 to check that
+Exception_Identity(Null_Occurrence) does return Null_Id.
 
 !appendix
 
@@ -61,19 +91,25 @@
 Null_Occurrence (type Exception_Occurrence is limited).
 
 We propose that a function should be added to Ada.Exceptions that
-would allow testing whether an exception occurrence is Null_Occurrence.
-In GNAT, we have added a child function Ada.Exceptions.Is_Null_Occurrence
+would allow testing whether an exception occurrence is
+Null_Occurrence.
+In GNAT, we have added a child function
+Ada.Exceptions.Is_Null_Occurrence
 for this purpose:
 
---  child function of Ada.Exceptions. It provides
--- nality for its parent package, and most reasonably
--- d function to that package, but this change cannot
+--  This is a GNAT-specific child function of Ada.Exceptions. It
+provides
+--  clearly missing functionality for its parent package, and most
+reasonably
+--  would simply be an added function to that package, but this
+change cannot
 --  be made in a conforming manner.
 
 function Ada.Exceptions.Is_Null_Occurrence
   (X    : Exception_Occurrence)
    return Boolean;
-   --  This function yields True if X is Null_Occurrence, and False otherwise
+   --  This function yields True if X is Null_Occurrence, and False
+otherwise
 
 ****************************************************************
 
@@ -92,7 +128,8 @@
 > function Ada.Exceptions.Is_Null_Occurrence
 >   (X    : Exception_Occurrence)
 >    return Boolean;
-> --  This function yields True if X is Null_Occurrence, and False otherwise
+> --  This function yields True if X is Null_Occurrence, and False
+otherwise
 
 This seems like a reasonable proposal, in any case, although it
 is obviously an amendment, not an interpretation.
@@ -112,9 +149,12 @@
 that is a mistake, though others might remember otherwise.
 >>
 
-Well I would be happy to allow this identity, though this would be a change
-(in GNAT we could add a child, but not change clear RM semantics), but
-if one is in the amendment business, perhaps allowing the above identity
+Well I would be happy to allow this identity, though this would be a
+change
+(in GNAT we could add a child, but not change clear RM semantics),
+but
+if one is in the amendment business, perhaps allowing the above
+identity
 is the cleanest approach.
 
 ****************************************************************

Questions? Ask the ACAA Technical Agent