[J3] Exception handling - Golang proposal

Van Snyder van.snyder at jpl.nasa.gov
Sun Jul 7 05:30:19 EDT 2019


On Sat, 2019-07-06 at 20:52 -0400, Steve Lionel via J3 wrote:

> One of the major features we've said we'd like to see in F202X is 
> "exception handling", but this is probably the least well defined (for 
> Fortran) of any of the features proposed. Tonight I ran across a 
> proposal being suggested for the Go language which bears some 
> similarities to at least one proposal I've seen for Fortran. Some in the 
> Go community don't like it.
> 
> I haven't studied it enough to see if there are any "take-aways" for 
> Fortran, but I found it worthwhile reading as I saw echoes of some of 
> our earlier discussions.
> 
> The actual proposal and discussion: 
> https://github.com/golang/proposal/blob/master/design/32437-try-builtin.md
> 
> Some other discussion: https://github.com/golang/go/issues/32437
> 
> Article about the "kerfluffle": 
> https://thenewstack.io/this-week-in-programming-do-or-not-do-there-is-no-try/
> 
> Steve



Detailed exception-handling requirements from the Steelman (final)
requirements document for what became Ada:

https://en.wikisource.org/wiki/Steelman_language_requirements#10._Exception_Handling

10. Exception Handling

10A. Exception Handling Facility. There shall be an exception handling
mechanism for responding to unplanned error situations detected in
declarations and statements during execution. The exception situations
shall include errors detected by hardware, software errors detected
during execution, error situations in built-in operations, and user
defined exceptions. Exception identifiers shall have a scope. Exceptions
should add to the execution time of programs only if they are raised.

10B. Error Situations. The errors detectable during execution shall
include exceeding the specified range of an array subscript, exceeding
the specified range of a variable, exceeding the implemented range of a
variable, attempting to access an uninitialized variable, attempting to
access a field of a variant that is not present, requesting a resource
(such as stack or heap storage) when an insufficient quantity remains,
and failing to satisfy a program specified assertion. [Note that some
are very expensive to detect unless aided by special hardware, and
consequently their detection will often be suppressed (see 10G).]

10C. Raising Exceptions. There shall be an operation that raises an
exception. Raising an exception shall cause transfer of control to the
most local enclosing exception handler for that exception without
completing execution of the current statement or declaration, but shall
not of itself cause transfer out of a function, procedure, or process.
Exceptions that are not handled within a function or procedure shall be
raised again at the point of call in their callers. Exceptions that are
not handled within a process shall terminate the process. Exceptions
that can be raised by built-in operations shall be given in the language
definition.

10D. Exception Handling. There shall be a control structure for
discriminating among the exceptions that can occur in a specified
statement sequence. The user may supply a single control path for all
exceptions not otherwise mentioned in such a discrimination. It shall be
possible to raise the exception that selected the current handler when
exiting the handler.

10E. Order of Exceptions. The order in which exceptions in different
parts of an expression are detected shall not be guaranteed by the
language or by the translator.

10F. Assertions. It shall be possible to include assertions in programs.
If an assertion is false when encountered during execution, it shall
raise an exception. It shall also be possible to include assertions,
such as the expected frequency for selection of a conditional path, that
cannot be verified. [Note that assertions can be used to aid
optimization and maintenance.]

10G. Suppressing Exceptions. It shall be possible during translation to
suppress individually the execution time detection of exceptions within
a given scope. The language shall not guarantee the integrity of the
values produced when a suppressed exception occurs. [Note that
suppression of an exception is not an assertion that the corresponding
error will not occur.]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20190707/9e34435e/attachment.html>


More information about the J3 mailing list