Get rid of "direct exceptions" and turn all exceptions into "normal exceptions", i.e. always use AError return value to signal an exception.
The current VM implementation uses setjmp/longjmp for handling "direct" exceptions and this bad for several reasons:
- It is tricky to free resources correctly when using the C API.
- C++ destructors may be ignored when a direct exception is raised.
- It is difficult to remember when an operation may raise a normal exception, and when it's safe to not check for an AError return.
In order not to make it too painful to write C extensions, support variants of common API functions that check for AError and perform a local return on errors, for example something like this:
#define AAppendArrayR(t, a, o) do { \
if (AIsError(AAppendArray(t, a, o))) return AError; } while (0)
This would give some of the benefits of direct exceptions without most of the problems.
Get rid of "direct exceptions" and turn all exceptions into "normal exceptions", i.e. always use AError return value to signal an exception.
The current VM implementation uses setjmp/longjmp for handling "direct" exceptions and this bad for several reasons:
In order not to make it too painful to write C extensions, support variants of common API functions that check for AError and perform a local return on errors, for example something like this:
This would give some of the benefits of direct exceptions without most of the problems.