On Wednesday, 16 April 2014 at 20:29:17 UTC, bearophile wrote:
Peter Alexander:(I assume that nothrow isn't meant to be there?)In D nothrow functions can throw errors.
Of course, ignore me :-)
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.
But then it isn't thread safe. Two threads trying to set and throw the same Error is a recipe for disaster.