Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site psivax.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!qantel!hplabs!sdcrdcf!psivax!friesen From: friesen@psivax.UUCP (Stanley Friesen) Newsgroups: net.lang.c Subject: Re: C Style Message-ID: <725@psivax.UUCP> Date: Mon, 16-Sep-85 12:35:31 EDT Article-I.D.: psivax.725 Posted: Mon Sep 16 12:35:31 1985 Date-Received: Sat, 21-Sep-85 05:22:41 EDT References: <180@chinet.UUCP> Reply-To: friesen@psivax.UUCP (Stanley Friesen) Organization: Pacesetter Systems Inc., Sylmar, CA Lines: 28 Keywords: which is better? In article <180@chinet.UUCP> rlk@chinet.UUCP (Richard L. Klappal) writes: > >The question: > Which of the following code segments is more understandable, > (readable, structured, etc) given the current attitudes > about the presence of goto's in programming? > Well, of the two, neither really great I prefer this one: > >versus NO GOTO VERSION > > for ( ; (((ch=getch()) < '1' || ch > '5') && ch != 'E') ; ) > putchar(BELL); > addch(ch); > refresh(); > That is unless the code is really deeply nested and I need to pop ou to the outer level on error. BTW, a small nit. Since the 'for' has no initialization or change expressions it is exactly equivalent to a 'while' statement - it would be more readable if you had written it that way, or as the someone else suggested, pull the getchar out of the condition and put it in the init and change expressions. -- Sarima (Stanley Friesen) UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen ARPA: ttidca!psivax!friesen@rand-unix.arpa