home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: TRY ... FINALLY
- Message-ID: <1992Dec19.180921.10536@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Dec18.094624.28329@us-es.sel.de> <MCGRANT.92Dec18050954@rascals.stanford.edu>
- Date: Sat, 19 Dec 1992 18:09:21 GMT
- Lines: 44
-
- In article <MCGRANT.92Dec18050954@rascals.stanford.edu> mcgrant@rascals.stanford.edu (Michael C. Grant) writes:
- >In article <1992Dec18.094624.28329@us-es.sel.de>
- >reindorf@us-es.sel.de (Charles Reindorf) writes:
- >
- > I have actually seen a post, I think on this newsgroup, concerning the equivalent
- > to Modula 3's TRY ... FINALLY clause. (This is exception handling related)
- >
- > If you have :
- > TRY
- > statements1
- > FINALLY
- > statements2
- > END
- >
- > "statements1" gets executed follwed by "statements2" but, if an exception
- > gets raised executing "statements1" then "statements2" gets executed before
- > re-throwing.
-
- >Yep, it's also called unwind-protect in lisp dialects... and it makes sense
- >to call it that, because after FINALLY are PROTECTED statements in that
- >they are executed when the stack is UNWOUND, even for non-local exits.
- >
- >I suppose it could be simulated by creating a local automatic version of
- >a class containing as its destructor any 'statement2' you wish. But, the
- >downside is that any variable it accesses must be enclosed inside that
- >class. Too bad.
- >
- You can fix this by making the function a member of the object.
- In fact, it can be made the constructor of the object.
- The destructor body has access to
- all the local variables of the function then, because those
- local variables are just data member of the object.
-
- Interestingly, the Cecil language doesn't have many
- control structures, instead it is designed in such a way that
- you can implement your own control structures easily using objects.
- (Cecil is prototype based, which makes inventing your own
- control structures 'on the fly' easy).
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-