Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!husc6!harvard!seismo!hao!hplabs!hpda!hpisoa2!hpitg!toram!chris@toram From: chris@toram Newsgroups: net.lang.c Subject: Re: Re: Jumping into blocks Message-ID: <149@toram> Date: Fri, 25-Apr-86 20:45:00 EDT Article-I.D.: toram.149 Posted: Fri Apr 25 20:45:00 1986 Date-Received: Tue, 13-May-86 03:10:00 EDT References: <737@bentley> Lines: 25 In article <737@bentley.UUCP> kwh@bentley.UUCP (KW Heuer) writes: >In article <275@copper.UUCP> copper!stevesu (Steve Summit) writes: >>Most people agree that goto's are pretty acceptable for handling >>error conditions. For instance: >> >> [example deleted] > > ... But here's a real example I keep running into: > > [example deleted] > >So, assuming that goatooze are acceptable for error handling, but jumping >into a block is forbidden, what's the best way to write this? Use two >braches, and hide the common code at the bottom of main()? Set an error >flag and test it outside the while? (Ugh, that requires an artificial >boolean *and* a break statement.) Make usage() a non-returning function >instead of a label? (My usual preference.) Duplicate the code? What's wrong with a flag and and "break"s? "Break" after an error condition is perfectly obvious, especially when the error test is right after the loop. Or duplicate the code, when it's so trivial. What's a couple of lines in the interest of readability? Sure "goto"s can sometimes make complicated things more readable (e.g., saving putting great chunks of code in several nests of "if"s), but why on earth use it to make a nice, straightforward error test obscure?