-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error handling overhaul, includes CC#1743 #29
Error handling overhaul, includes CC#1743 #29
Conversation
(Note QUIT now takes an INTEGER! value only, and has no /NOW refinement. A small step for now, but ideally EXIT will be shifted to act as QUIT/RETURN, and QUIT will be arity zero meaning EXIT 0) This is a major rewrite of the setjmp/longjmp-based error handling, and it's not really that reasonable or feasible to break it up much more than this. These things are all inter-related. Central ideas are that there aren't two separate saved states to worry about (Halt_State is integrated into Saved_State) and the PUSH_CATCH/DROP_CATCH macros are clearer and simpler, with less chance for making mistakes in usage. The mechanism for including a REBVAL associated with an error has been simplified and formalized a little more. Though simpler, an attempt to further tighten the grip on this "sneaky" way of having one error-per-task turned out to complicate the code a bit too much, and so it could still be improved with some better asserts.
I specifically targeted IS_RETURN for deletion originally because there was a new ANY-FUNCTION! class of value called RETURN!, and it was easy enough to test VAL_ERR_NUM(error) against RE_RETURN to remove the competition between the tests. I'll probably not be adding a new data type in the formal commit, but still it's better to be explicit about the error number testing, especially given there are so few instances of that.
@earl pointed out that the 'assert(VAL_ERR_NUM(error) != 0' was a bit of a non-sequitur. If error numbers aren't ever zero, that guarantee should be established somewhere less random. I started a basic ASSERT_ERROR so that the verification is done at time of throw in a debug build.
Fixes cases like 'print return 10', adds in some simple assertions for sanity checking.
After the initial draft for commentary on methodology (prior to anything other than smoke testing of 'test suite did not crash'), going over the points found problems that were corrected. Having gotten back up to date on precisely why and when an error is "thrown" or just bubbled up, this could use another pass of improvements. But it seems to be working now. Committed in rebased form as: Review comments still welcome of course, but the show must go on. |
PROMPT REVIEW REQUESTED...a lot builds on this, and it's
taking a very long time as it is to try and ramp the code up to where
I'd like it to be.
(Note QUIT now takes an INTEGER! value only, and has no /NOW
refinement. A small step for now, but ideally EXIT will be shifted to
act as QUIT/RETURN, and QUIT will be arity zero meaning EXIT 0)
This is a major rewrite of the setjmp/longjmp-based error handling,
and it's not really that reasonable or feasible to break it up much
more than this. These things are all inter-related.
Central ideas are that there aren't two separate saved states
to worry about (Halt_State is integrated into Saved_State) and the
PUSH_CATCH/DROP_CATCH macros are clearer and simpler,
with less chance for making mistakes in usage.
The mechanism for including a REBVAL associated with an error
has been simplified and formalized a little more. Though simpler,
an attempt to further tighten the grip on this "sneaky" way of having
one error-per-task turned out to complicate the code a bit too much,
and so it could still be improved with some better asserts.