On Sun, Sep 23, 2012 at 10:40 AM, Stepan Koltsov
<
stepan....@gmail.com> wrote:
> Hi, again.
>
> Does anybody think anything about this feature:
>
> * should it be implemented some other way?
> * does this feature worth inclusion into the compiler?
>
> Meanwhile, I improved the patch:
>
> * tests fixed
> * file and line number of throw statement is now captured
>
> See two last patches in branch:
>
https://github.com/stepancheg/clay/commits/bte
Hi Stepan. Sorry for missing your first message. This is a great idea,
and a reasonable implementation. Performance should not be an issue
because the backtrace only needs to be captured when an exception is
actually thrown, and exceptions shouldn't be thrown on a critical
path. It would be nice not to expose those magic __exc_ identifiers,
though I can't think of a good way to avoid doing so without putting
that data in the exception itself or extending the syntax of catch.
The exceptionAs and exceptionAsAny hooks could be implemented a bit
more cleanly without named returns using a scope guard:
overload exceptionAs(#T, exp:RawPointer) : T, Backtrace, StringLiteralRef, Int {
finally freeRawMemory(exp);
return moveUnsafe(nestedVariantAs(exceptionObject(exp).exception,
T)), moveUnsafe(exceptionObject(exp).backtrace),
exceptionObject(exp).file,
exceptionObject(exp).line;
}
Other than that, it looks good.
-Joe