From: bouncer@dev.null   
      
   Dave Abrahams wrote:   
      
   > on Sun Jun 24 2012, Wil Evers wrote:   
   >   
   >> It can only mean that the destructor is expected to do more than   
   >> just resource management.   
   >>   
   >> And that, I think, is the heart of the matter: is it a good idea to   
   >> change the language to provide better support for these other uses?   
   >> Even if it is technically feasible to do so, what will we gain?   
   >   
   > Two things I can think of:   
   >   
   > 1. Removal of gratuitous brittleness. In that sense, it's the same   
   > as the deprecation of dynamic exception-specifications.   
   > Programmers shouldn't have to worry needlessly about gotchas.   
      
   That's an excellent point, why call terminate() if the language can do   
   better? However, it does seem to be at odds with C++11's implicit   
   noexcept rule for destructors. To be honest, I don't think I   
   understand the reasons behind that decision; do you think it ought   
   to be revisited?   
      
   > 2. Legitimacy for idioms like "throwing scopeguard"   
   >   
   >> The idea that destructors are meant for automatic resource   
   >> management is the key design principle behind RAII;   
   >   
   > At this point what they were "meant for" is irrelevant; they're   
   > primarily used that way, but they also get used for other things all   
   > the time (e.g. logging at scope exit).   
      
   Agreed; it makes sense for such a destructor to throw if it fails to   
   update the log. Of course, the repackaging you're proposing does   
   imply that the thrown exception cannot always be caught like we're   
   used to now, but I guess that's a price I'd be willing to pay.   
      
   >> the idea that destructors don't throw is a hard requirement in many   
   >> parts of the standard library, and I suspect lots of user code is   
   >> based on these assumptions too. Why make it easier to break the   
   >> rules?   
   >   
   > The rules are already "broken." :-) It's time they were loosened.   
      
   Just curious: does that mean you think it's possible to lift the   
   current ban on container elements with throwing destructors?   
      
   Thanks,   
      
   - Wil   
      
      
   --   
    [ 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)   
|