exceptions vs error codes
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 11 01:50:01 PDT 2016
On Sunday, 10 July 2016 at 21:31:57 UTC, Chris Wright wrote:
> On Sun, 10 Jul 2016 16:57:49 +0000, ketmar wrote:
>
>> On Sunday, 10 July 2016 at 16:47:31 UTC, Chris Wright wrote:
>>> You do need a try/catch in every annotated function to catch
>>> runtime exceptions like OutOfMemoryError.
>>
>> as a side note: it is even not guaranteed that one *can* catch
>> Error. and it is plainly wrong to try to continue execution
>> after that, as program is in undefined state.
>
> Array bounds errors, then.
any Error. spec clearly says that throwing Error doesn't
guarantee proper unwinding (and by that, it may skip as many
catch blocks as it want), and program is in undefined state after
catching Error.
in DMD, it just happened to be implemented in a way that it is
possible to catch many errors, get unwinding, and such. but it
isn't a requirement. and, by the way, by writing different
spec-compliant implementation, one can break alot of unittests,
as many unittests catching AssertError.
and no, i don't know how to write a reliable and spec-compliant
unittest in D with `assert`s.
More information about the Digitalmars-d
mailing list