@nogc and exceptions

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 19 09:41:33 PDT 2014


On Friday, 19 September 2014 at 11:36:29 UTC, Jakob Ovrum wrote:
> That might be sufficient for a particular application like 
> Sociomantic's, but it's not sufficient for library code in 
> general. Such chains aren't logic errors and can easily occur 
> in the wild.
>
> The point of exception chaining is so exceptions can be thrown 
> in destructors and such. In library code, these destructors 
> don't know what exception is in flight, so they can only assume 
> it could be any exception. If self-referencing chains were 
> illegal and exceptions were statically allocated, then the 
> conclusion is that these destructors can't throw anything after 
> all, because that exception might already be in flight. As 
> such, exception chaining would be completely useless.

This is pretty much saying that anything should be able to throw 
anything. For me it sounds as flawed application - if recurrent 
chaining happens when handling destructor, most likely there is a 
fundamental programming error in application logic (some sort of 
cyclic dependency) and it should be pointed to and fixed.

Probably there is some convincing example of such legal code but 
I can't imagine it on my own.


More information about the Digitalmars-d mailing list