Version 1.5 of ais/ai-00361.txt

Unformatted version of ais/ai-00361.txt version 1.5
Other versions for file ais/ai-00361.txt

!standard 11.3(2)          04-05-27 AI95-00361/03
!standard 11.3(3)
!standard 11.3(4)
!standard 11.4.1(10)
!class amendment 03-11-04
!status Amendment 200Y 04-01-13
!status WG9 Approved 04-06-18
!status ARG Approved 9-0-2 03-12-13
!status work item 03-11-04
!status received 03-11-04
!priority Medium
!difficulty Easy
!subject Raise with message
!summary
A string expression may be specified in a raise statement.
!problem
It would be nice to have a simpler syntax for specifying a message when raising an exception, as the current method of calling Raise_Exception is quite cumbersome.
!proposal
(See wording.)
!wording
Replace 11.3(2) by:
raise_statement ::= raise; | raise exception_name [with string_expression];
Add after 11.3(3):
Name Resolution Rules
The expression, if any, in a raise_statement, is expected to be of type String.
Replace the second sentence of 11.3(4) by:
For the execution of a raise_statement with an exception_name, the named exception is raised. If a string_expression is present, a subsequent call of Ada.Exception.Exception_Message on the occurrence being raised will return that string.
Replace 11.4.1(10) by:
Raise_Exception raises a new occurrence of the identified exception.
Exception_Message returns the message associated with the given Exception_Occurrence. For an occurrence raised by a call to Raise_Exception, the message is the Message parameter passed to Raise_Exception. For an occurrence raised by a raise_statement with an exception_name and a string_expression, the message is the string_expression. For an occurrence raised by a raise_statement with an exception_name but without a string_expression, the message is a string giving implementation-defined information about the exception occurrence.
Reraise_Occurrence reraises the specified exception occurrence.
!discussion
Ideally we would like to say that the expression is expected to be of any string type. This would make it possible to raise exceptions with localized strings. Unfortunately, this would make any literal ambiguous, and literals are expected to be the most frequent expressions in raise-with statements. We don't want to force users to use qualification all over the place.
!example
raise Not_Valid_Error with "Parent not valid";
!corrigendum 11.3(2)
Replace the paragraph:
raise_statement ::= raise [exception_name];
by:
raise_statement ::= raise; | raise exception_name [with string_expression];
!corrigendum 11.3(3)
Insert after the paragraph:
The name, if any, in a raise_statement shall denote an exception. A raise_statement with no exception_name (that is, a re-raise statement) shall be within a handler, but not within a body enclosed by that handler.
the new paragraph:
Name Resolution Rules
The expression, if any, in a raise_statement, is expected to be of type String.
!corrigendum 11.3(4)
Replace the paragraph:
To raise an exception is to raise a new occurrence of that exception, as explained in 11.4. For the execution of a raise_statement with an exception_name, the named exception is raised. For the execution of a re-raise statement, the exception occurrence that caused transfer of control to the innermost enclosing handler is raised again.
by:
To raise an exception is to raise a new occurrence of that exception, as explained in 11.4. For the execution of a raise_statement with an exception_name, the named exception is raised. If a string_expression is present, a subsequent call of Ada.Exception.Exception_Message on the occurrence being raised will return that string. For the execution of a re-raise statement, the exception occurrence that caused transfer of control to the innermost enclosing handler is raised again.
!corrigendum 11.4.1(10)
Replace the paragraph:
Raise_Exception raises a new occurrence of the identified exception. In this case, Exception_Message returns the Message parameter of Raise_Exception. For a raise_statement with an exception_name, Exception_Message returns implementation-defined information about the exception occurrence. Reraise_Occurrence reraises the specified exception occurrence.
by:
Raise_Exception raises a new occurrence of the identified exception.
Exception_Message returns the message associated with the given Exception_Occurrence. For an occurrence raised by a call to Raise_Exception, the message is the Message parameter passed to Raise_Exception. For the occurrence raised by a raise_statement with an exception_name and a string_expression, the message is the string_expression. For the occurrence raised by a raise_statement with an exception_name but without a string_expression, the message is a string giving implementation-defined information about the exception occurrence.
Reraise_Occurrence reraises the specified exception occurrence.
!ACATS test
An ACATS test (or additional test cases in the existing tests) should be constructed to test this feature.
!appendix

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

Questions? Ask the ACAA Technical Agent