home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,317 of 33,346   
   Zeljko Vrba to Wil Evers   
   Re: Developing an exception hierarchy   
   19 May 12 12:46:03   
   
   From: mordor.nospam@fly.srk.fer.hr   
      
   On 2012-05-19, Wil Evers  wrote:   
   >   
   > It is close()'s surprising double-duty nature that causes the   
   > problem we're discussing here.  Destructors are compiler-generated   
   > callbacks that tell us to release our resources; they were simply   
   > not designed for anything else.   
   >   
      
   In principle, I agree, but you may find examples where nontrivial work   
   is done in destructors, for example, unlocking a mutex.   
      
   So it seems that destructors are usable only for doing work that   
   cannot fail, which is, in practice, just freeing memory. (An   
   alternative is to ignore errors in destructors and hope for the best   
   -- as with close and mutex examples.)   
      
   Maybe the common wisdom of not throwing from a destructor is wrong --   
   why is everybody so afraid of terminate() being called when a custom   
   terminate handler can be installed?   
      
      
   --   
         [ 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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca