home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 12930 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.8 KB

  1. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!UB.com!igor!thor!rmartin
  2. From: rmartin@thor.Rational.COM (Bob Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: GOTO, was: Tiny proposal for named loops.
  5. Message-ID: <rmartin.714862459@thor>
  6. Date: 26 Aug 92 20:54:19 GMT
  7. References: <TSOS.61.714395736@uni-duesseldorf.de> <1992Aug21.203635.2917@alias.com>     <rmartin.714668024@thor> <2299@devnull.mpd.tandem.com>     <rmartin.714749390@thor> <TMB.92Aug25220434@arolla.idiap.ch>
  8. Sender: news@Rational.COM
  9. Lines: 32
  10.  
  11. tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
  12.  
  13. |After many postings extolling the evils of "break", "return" and other
  14. |"non-structured" exits from blocks, Bob Martin writes in article
  15. |<rmartin.714749390@thor>:
  16.  
  17. |   In a real application, when confronted with memory outage, I would
  18. |   throw an exception, call assert, or just plain exit.
  19.  
  20. |What is an exception exception other than an exit from a block? How is
  21. |that going to leave your "pre- and postconditions" intact?
  22.  
  23. Exceptions do not return to the invoking block, they return to another
  24. block which is declared to catch the exception.
  25.  
  26. |Altogether, I find Bob's arguments against "break" unconvincing. There
  27. |is nothing wrong with using "break", exceptions, or even the
  28. |occasional "goto" in C++, since C++ has mechanisms (destructors) that
  29. |can be used to take care of cleanup jobs when a block is exited from
  30. |anywhere; simply use them.
  31.  
  32. And I disagree, in part.  Yes, use exceptions and exits where
  33. necessary.  But avoid break and continue where possible, and avoid
  34. goto altogether.  
  35.  
  36.  
  37.  
  38. --
  39. Robert Martin                        Training courses offered in:
  40. R. C. M. Consulting                       Object Oriented Analysis
  41. 2080 Cranbrook Rd.                        Object Oriented Design
  42. Green Oaks, Il 60048 (708) 918-1004       C++
  43.