home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / arch / 10524 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.2 KB  |  50 lines

  1. Newsgroups: comp.arch
  2. Path: sparky!uunet!haven.umd.edu!purdue!yuma!csn!raven!rcd
  3. From: rcd@raven.eklektix.com (Dick Dunn)
  4. Subject: Re: A challenge to the anti-goto
  5. Message-ID: <1992Nov8.065551@eklektix.com>
  6. Organization: eklektix - Boulder, Colorado
  7. References: <Bx0BuG.s4@mentor.cc.purdue.edu> <1cvoctINNmhs@agate.berkeley.edu> <1992Nov5.145032.6678@sei.cmu.edu>
  8. Date: Sun, 8 Nov 1992 06:55:51 GMT
  9. Lines: 39
  10.  
  11. firth@sei.cmu.edu (Robert Firth) writes:
  12. >jhauser@pine.CS.Berkeley.EDU (John Hauser) writes:
  13. >>    If we've known about this problem for twenty years, why don't we
  14. >>    have more powerful `break' instructions in our existing languages??
  15. >
  16. >We do.  Exactly the construct you require is found in Ada...
  17. ...
  18. >My question: if we have had the *solution* to this problem for ten years,
  19. >why don't more people know about it and use it?
  20.  
  21. The "solution" predates Ada by quite a bit, of course...
  22.  
  23. The reason we don't see it more often is that it's turned out not to be
  24. as good an idea as people think when they first consider it.
  25.  
  26. Single-level "break" can make some pieces of code a lot easier to read.
  27. It's simple, useful, and straightforward.
  28.  
  29. Multi-level "break" is still useful, but because it can reach further out,
  30. it has several practical disadvantages:
  31.     - It requires some sort of labeling, to identify how far out (how
  32.       many levels) you're exiting...this gives it a little of the
  33.       flavor of a goto.
  34.     - In general it takes you "farther" out in the code--the transfer
  35.       of control will on the average be more distant, hence generally
  36.       harder to follow.
  37.     - It destroys a certain sense of "nesting"--control from within
  38.       one or more inner structures can reach various outer points.
  39. All of these reasons taken together still wouldn't condemn the idea of a
  40. multi-level break if it were useful enough.  But it turns out to be one of
  41. those 90% situations--single-level break covers 90% of the need, and the
  42. remaining 10% doesn't justify the added complexity of another construct.
  43.  
  44. Therefore, most languages have omitted it.  It's not that it wouldn't be
  45. useful, but only the consensus is that it isn't useful enough to justify
  46. the added baggage in the language.
  47. -- 
  48. Dick Dunn    rcd@raven.eklektix.com   -or-   raven!rcd    Boulder, Colorado
  49.     ...Simpler is better.
  50.