Rethrow an exception like in C++?

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 8 01:14:23 PST 2013


On Friday, March 08, 2013 10:07:58 Chris Cain wrote:
> 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.

I agree.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list