Exceptions in @nogc code

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 1 17:11:02 PDT 2017


On Saturday, 1 April 2017 at 19:52:14 UTC, Eugene Wissner wrote:
> If I understand correctly exceptions are anyway special class 
> objects.

No, exceptions are just ordinary objects, they just happen to 
inherit from Throwable which is the interface the compiler 
requires for the `throw` statement.

> The same as Errors are special class objects, they can be 
> thrown regardless nothrow and @nogc, because these aren't 
> recoverable errors.

@nogc doesn't prevent throwing anything, you can throw an 
Exception in it too.

But indeed, Error is exempt from nothrow but other than that, it 
is also just a normal class.


More information about the Digitalmars-d mailing list