Alexander wrote:
On 13.05.2011 10:25, Don wrote:
Are you talking about *finalizers* or *destructors* ?
Destructors as defined in D spec. There are no finalizers (yet), AFAIK.
The things in classes which the spec calls "destructors" are finalizers,
not destructors.
Throwing from inside a destructor should definitely work (unlike C++).
How? Destructor is called by the GC when object is deleted. When and where
(which thread) this happens is unknown, it is done outside of regular flow of
execution - so who and where can catch this exception? So, like any other
uncatched exception,
it will terminate the program.
If the GC calls it, it's a finalizer, not a destructor.
Structs have destructors, and it's perfectly OK to throw inside them.