From: francis.glassborow@btinternet.com   
      
   On 15/06/2012 19:21, Zeljko Vrba wrote:   
   > On 2012-06-14, sunseraphic wrote:   
   >   
   >> How do you think about to throw another exception in the finally   
   > block? :)   
   >   
   > This is supported in Java. What happens, apparently (concluded from   
   > some quick net searches instead of reading the spec), is that the   
   > first exception disappears and exception from finally is propagated.   
   > (The question also arises: what happens if return is executed in the   
   > middle of the finally block?)   
   >   
   > Incidentally, this very same search turns up advice about 1) not   
   > throwing in finally and 2) not letting exceptions propagate from   
   > finally. But it is not absolutely discouraged; it is legitimate   
   > to throw from finally in certain cases.   
   >   
   >   
   And as far as C++ is concerned it is legitimate to throw from a dtor,   
   nonetheless it is strongly discouraged because it is usually a faulty   
   design.   
      
   One of the main the problems is how to provide commit or roll-back   
   semantics in C++. If only we had a way to reliably identify when we are   
   in the process of stack unwinding as a result of an exception, this   
   could often be done within a dtor, throwing an exception in the   
   roll-back case.   
      
   Francis   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|