[comp.lang.eiffel] exiting a `rescue' without creating an exception

gossett@bthpyd.UUCP (Eric Gossett) (02/10/90)

There are currently two options available in a `rescue' clause:

1. Try to fix the root problem and then `retry' the routine.

2. Clean up as gracefully as possible, then create an exception in the
   calling routine.


In some cases, a particular exception may indicate the need to terminate
the routine without a retry or an exception in the calling routine. (For 
example, when finding determinants using a factorization, a step at which
there is no nonzero pivot element would cause a division by zero, but it
also indicates that the determinant is zero.)  At present, such a situation
must be programmed as:

local
  exceptional_case : BOOLEAN; 
do
  if exceptional_case then
    Result := <something>
  else
    <normal, long algorithm>
  end
rescue
  <fix the exception>
  exceptional_case := true;
  retry
end 

 
I would like to propose a new construct that would be an alternative to
`retry', namely, `normal_exit'.  The rescue clause could take appropriate
action, then terminate the routine without raising an exception in the 
calling routine.  This would eliminate the need for the awkward outer loop
in the program skeleton above.

bertrand@eiffel.UUCP (Bertrand Meyer) (02/17/90)

In <501@bthpyd.UUCP>, gossett@bthpyd.UUCP (Eric Gossett) discusses
the problem of a rescue clause that can ``fix'' the cause of the exception.

The ability to ``continue'' on a given exception, after calling the
appropriate ``continue_on_signal'' routine, addresses this
problem at least in part. See ``Eiffel: The Libraries'', page 20.
The mechanism may need to be generalized.
-- 
-- Bertrand Meyer
bertrand@eiffel.com