Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site toram.UUCP Path: utzoo!utcs!lsuc!mnetor!toram!chris From: chris@toram.UUCP (Chris Robertson) Newsgroups: net.lang.c Subject: Re: Jumping into blocks Message-ID: <149@toram.UUCP> Date: Fri, 25-Apr-86 11:45:45 EST Article-I.D.: toram.149 Posted: Fri Apr 25 11:45:45 1986 Date-Received: Sat, 26-Apr-86 10:42:04 EST References: <1370@ism780c.UUCP> <360@hadron.UUCP> <275@copper.UUCP> <737@bentley.UUCP> Reply-To: chris@toram.UUCP (God Himself) Organization: Toram/Globe-Tek Systems Ltd., Toronto, Canada Lines: 25 Summary: 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?