DIP60: @nogc attribute

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 21 13:05:51 PDT 2014


Am Sun, 20 Apr 2014 08:19:45 +0000
schrieb "monarch_dodra" <monarchdodra at gmail.com>:

> D static initialization doesn't work the same way. Everything is 
> initialized as the program is loaded, […]

Ah ok, it's all good then :)

> Also, just doing this is good enough:
> 
> //----
> void foo() @nogc
> {
>     static err = new Error("badthing happened");
>     if (badthing)
>         throw err;
> }
> //----
> 
> It does require the message be known before hand, and not custom 
> "built". But then again, where were you going to allocate the 
> message, and if allocated, who would clean it up?
> 
> --------
> 
> That said, while the approach works, there could be issues with 
> re-entrance, or chaining exceptions.

Yes, we've discussed the issues with that approach in other
threads. At least this allows exceptions to be used at all.

-- 
Marco



More information about the Digitalmars-d mailing list