Path: utzoo!utgpu!watmath!att!pacbell!ames!excelan!ames!uakari.primate.wisc.edu!ginosko!uunet!munnari.oz.au!cs.mu.oz.au!ok From: ok@cs.mu.oz.au (Richard O'Keefe) Newsgroups: comp.os.minix Subject: Re: gotos Message-ID: <2294@munnari.oz.au> Date: 4 Oct 89 08:46:22 GMT References: <24962@louie.udel.EDU> <1989Sep29.183703.1275@utzoo.uucp> <1989Oct3.131847.15627@ntvax.uucp> Sender: news@cs.mu.oz.au Lines: 21 In article <1989Oct3.131847.15627@ntvax.uucp>, jbeard@ntvax.uucp (Jeff Beardsley) writes: > Actually even the use of goto for a multi-level break/continue can easily > be avoided by taking the entire multi-level structure, making it into a > function of its own, and using return. > This gets rid of the goto statement needed for multi-level break as well > as making the code more readable. Therefore I believe the NO-GOTO blanket > statement *IS* a defensible position. The snag with this is that every variable which the formerly embedded structure shared with its containing function now becomes a global variable. (In Pascal, "global" with respect to the new function; in C, "global" in the sense of not local to any function, though perhaps local to the file.) You should be aware that global variables are a maintenance problem in themselves; trading one goto for five globals is rather like bending down to pick up 10 cents and dropping a dollar. The answer is not to insert a goto and then patch it out by one or another even more dubious dodge, but to follow a design method (such as the one described by Dijkstra, Feijen, Gries, and others) where you never need a goto or a multilevel loop exit in the first place.