home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / c / 11556 < prev    next >
Encoding:
Internet Message Format  |  1992-07-24  |  1.9 KB

  1. Xref: sparky comp.lang.c:11556 comp.lang.c++:11467
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!uka!i41s14!prechelt
  3. From: prechelt@i41s14.ira.uka.de (Lutz Prechelt)
  4. Newsgroups: comp.lang.c,comp.lang.c++
  5. Subject: exit many loops at once (was: Pascal vs C)
  6. Date: 24 Jul 1992 12:33:18 GMT
  7. Organization: University of Karlsruhe, FRG
  8. Lines: 38
  9. Distribution: world
  10. Message-ID: <14otaeINNqoh@iraul1.ira.uka.de>
  11. References: <1992Jun13.152010.15968@aplcen.apl.jhu.edu> <1992Jun13.220259.17547@beaver.cs.washington.edu> <1992Jul22.201454.26298@microsoft.com>
  12. NNTP-Posting-Host: i41s14.ira.uka.de
  13. Keywords: refinements, goto, leave, break
  14.  
  15. In article <1992Jul22.201454.26298@microsoft.com>, philco@microsoft.com (Phillip Cooper) writes:
  16. |> In article <1992Jun13.220259.17547@beaver.cs.washington.edu> andrewb@lynx.cs.washington.edu (Andrew Berg) writes:
  17. |> >ded@aplcen.apl.jhu.edu (nod sivad) writes:
  18. |> >: >You can use "goto" e.g.
  19. |> >: >
  20. |> >: >{
  21. |> >: >   for(...) {
  22. |> >: >      for(...) {
  23. |> >: >         if(...) goto exloop;
  24. |> >: >      }
  25. |> >: >   }
  26. |> >: >exloop:
  27. |> >: >}
  28. |> >: >
  29. |> >: >Sure, it is not a very good style, but is should work.
  30.  
  31. Hmm. The style can be improved by using refinements:
  32. Put all three loops into one refinement called "threeloops" and replace
  33. the goto by  
  34.   leave `threeloops;
  35. This is structured and is just a generalization of 
  36.   break;
  37.  
  38. The C-Refine preprocessor that introduces refinements into C or C++
  39. is available for anonymous ftp from
  40.   iraun1.ira.uka.de [129.13.10.90]
  41.   /pub/gnu/crefine.3.0.tar.Z
  42.  
  43. It also appeared on comp.sources.reviewed as v02i013 to v02i19
  44. on July 15th, 1992
  45.  
  46.   Lutz
  47.  
  48. -- 
  49. Lutz Prechelt   (email: prechelt@ira.uka.de)            | Whenever you 
  50. Institut fuer Programmstrukturen und Datenorganisation  | complicate things,
  51. Universitaet Karlsruhe;  D-7500 Karlsruhe 1;  Germany   | they get
  52. (Voice: ++49/721/608-4317, FAX: ++49/721/694092)        | less simple.
  53.