Rethrow an exception like in C++?
Chris Cain
clcain at uncg.edu
Fri Mar 8 01:07:58 PST 2013
On Friday, 8 March 2013 at 09:01:14 UTC, Jonathan M Davis wrote:
> If that's the case, I really don't see what the problem is.
> It's just a few
> characters difference.
To be honest, the way I look at it, D does this _better_.
"throw;" looks like magic and it's accessing global (potentially
mutable) state to do something. I haven't done much research into
C++'s handling of exceptions (and, in particular, this feature),
but I'd be _very_ weary of doing that without knowing whether
this global state is thread local or shared. If it's shared, you
would have some nice heisenbugs pop up if this was used in
multithreaded code.
Using "catch(Exception E) { throw Trace(E); }" is more explicit
to what Trace needs to work and, IMO, a better design.
More information about the Digitalmars-d-learn
mailing list