[CLN-list] Overriding read_number_bad_syntax on OS X

Richard B. Kreckel kreckel at ginac.de
Sat Jul 28 19:37:59 CEST 2007


Richard B. Kreckel wrote:
> Ron Garret wrote:
>>> Thanks for these timings. I'm now convinced that it's worth throwing
>>> exceptions and dropping support for -fno-exceptions. These worst- 
>>> case 10% are acceptable.
>>
>> We're in violent agreement.
> 
> Unfortunately, my time is very limited. But I'm planning to transform 
> the aborting functions one-to-one to throw statement. Much like the 
> (untested) patch attached does for read_number_bad_syntax, 
> read_number_eof, and read_number_junk.
> 
> Unless someone raises objections, I'll proceed in the same way with 
> cl_abort, cl_error_division_by_0, cl_as_error, cl_notreached_abort, 
> uninitialized_ring, uninitialized_error, cl_error_floating_point_nan, 
> cl_error_floating_point_overflow, cl_error_floating_point_underflow, 
> cl_ash_error, cl_error_exquo, and maybe others.
> 
> I don't think there will be an impressive exception class hierarchy. 
> Deriving all input exceptions from one common base makes sense, though. 
> Maybe it would also be useful to derive all CLN exceptions from one 
> common base, which is in turn derived from std::runtime_error. But that 
> should be enough, I think.


A few minutes ago, I've committed a patch to the main branch that gets 
rid of all those nonreturning functions and instead throws exceptions of 
type cln::runtime_exception or derived. runtime_exception is in turn 
derived from std::runtime_error and inherits the .what() member function 
which can be used to query the cause of the exception. Here is the 
current hierarchy of exception types (with corresponding previous 
nonreturning functions in parenthesis):

runtime_exception  (was roughly: cl_abort)
  +- division_by_0_exception  (was: cl_error_division_by_0)
  +- as_exception  (was: cl_as_error)
  +- notreached_exception  (was: cl_notreached_abort)
  +- uninitialized_exception  (was: uninitialized_error)
  +- uninitialized_ring_exception  (was: uninitialized_ring)
  +- exquo_exception  (was: cl_error_exquo)
  +- ash_exception  (was: cl_ash_error)
  +- floating_point_exception
  |   +- floating_point_nan_exception  (was: cl_error_floating_point_nan)
  |   +- floating_point_overflow_excption  (was: 
cl_error_floating_point_overflow)
  |   `- floating_point_underflow_exception  (was: 
cl_error_floating_point_underflow)
  `- read_numger_exception
      +- read_number_bad_syntax_exception  (was: read_number_bad_syntax)
      +- read_number_junk_exception  (was: read_number_junk)
      `- read_number_eof_exception  (was: read_number_eof)

Cheers
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the CLN-list mailing list