Truly @nogc Exceptions?
welkam
wwwelkam at gmail.com
Sun Oct 21 15:14:40 UTC 2018
On Thursday, 20 September 2018 at 10:48:35 UTC, Atila Neves wrote:
> What's the fix? Have the compiler insert a call to the
> exception's destructor at the end of the `catch(scope
> Exception)` block.
If I understood you correctly then we have same idea. If
exception is not handled or re thrown then scope "exits" trough
scope(failure) in which case no deallocation should be performed
and only if scope "exits" trough scope(success), meaning
exception/s were handled, destructors need to be called.
To make exceptions nogc we need destructors that are aware of how
scope was exited like:
~ this(exit) ( ) {}
~ this(success) ( ) {}
~ this(failure) ( ) {}
With this its easy to make all exceptions nogc
More information about the Digitalmars-d
mailing list