home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18237 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.4 KB  |  57 lines

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