DIP60: @nogc attribute

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 16 13:29:16 PDT 2014


Peter Alexander:

> (I assume that nothrow isn't meant to be there?)

In D nothrow functions can throw errors.


> You could do something like this:
>
> void foo() @nogc
> {
>     static err = new Error();
>     if (badthing)
>     {
>         err.setError("badthing happened");
>         throw err;
>     }
> }

To be mutable err also needs to be __gshared.

Bye,
bearophile


More information about the Digitalmars-d mailing list