[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using C++ exceptions instead of error_state
From: |
John W. Eaton |
Subject: |
Using C++ exceptions instead of error_state |
Date: |
Mon, 22 Dec 2014 06:03:15 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0 |
I've been experimenting with having the error function throw a C++
exception instead of setting error_state. The current draft of my patch
is attached. All the tests that were passing before the change appear
to still be passing, so I think it is mostly functional.
With these changes, you can simply write
if (condition)
error ("lookout!");
... more code that should only execute if there is no error ...
and the error message and stack trace will be generated and execution
will jump to the top level magically. There's no longer any need to
check the value of error_state after operations that might generate
error messages. This change will make error handling in Octave's C++
code much more like what is done in .m files.
The error_state variable remains because a lot of code still uses it.
There are more than 1600 locations where it is used in core Octave that
I have not yet fixed.
Even though it will require quite a bit more work to finish this change
(those 1600+ uses of error_state, for one thing) I think it would be a
big step forward.
Comments? Objections?
jwe
exception-error-diffs.txt
Description: Text document
- Using C++ exceptions instead of error_state,
John W. Eaton <=