home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!caen!spool.mu.edu!umn.edu!csus.edu!borland.com!pete
- From: pete@borland.com (Pete Becker)
- Subject: Re: TRY ... FINALLY
- Message-ID: <1992Dec18.172233.18001@borland.com>
- Originator: pete@genghis.borland.com
- Keywords: Exception Handling TRY FINALLY
- Sender: news@borland.com (News Admin)
- Organization: Borland International
- References: <1992Dec18.094624.28329@us-es.sel.de>
- Date: Fri, 18 Dec 1992 17:22:33 GMT
- Lines: 30
-
- In article <1992Dec18.094624.28329@us-es.sel.de> reindorf@us-es.sel.de (Charles Reindorf) writes:
- >
- >The important point here is that ANY exit from the TRY block results in "statements2"
- >being executed, this includes the equivalent of returns, branches, break, continue,
- >and normal exit from the loop. It is therefore *not* equivalent to the C++ example ...
- >
- >
- > try
- > {
- > statements1
- > }
- > catch(...)
- > { statements2
- > throw;
- > }
- >
- >Is there any proposal in the ANSI C++ committee to introduce some sort of "TRY ... FINALLY"
- >type of clause into C++. I have found that this is an extremely useful construct (even
- >in the absence of exceptions) for putting general "clean-up" code in the "statements2" section
- >which frees up new'ed memory, resets state variables, and so-forth. I cannot think of any
- >other concise and wieldy way of doing it.
- >
-
- Code that must be executed whenever a function returns can be put
- in a destructor. Since such code is typically cleaning up things that were
- done earlier in the same function, that probably means that the earlier stuff
- should have been done in a constructor. Which, in turn, means that you're
- dealing with a class.
- -- Pete
-
-