Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site peregrine.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!sdcrdcf!trwrb!scgvaxd!felix!peregrine!mike
From: mike@peregrine.UUCP (Mike Wexler)
Newsgroups: net.lang.c
Subject: Re: C Style
Message-ID: <158@peregrine.UUCP>
Date: Wed, 18-Sep-85 13:28:33 EDT
Article-I.D.: peregrin.158
Posted: Wed Sep 18 13:28:33 1985
Date-Received: Mon, 23-Sep-85 00:31:33 EDT
References: <180@chinet.UUCP>
Organization: Peregrine Systems, Irvine, Ca
Lines: 39

> 
> The question:
> 	Which of the following code segments is more understandable,
> ...
> versus NO GOTO VERSION
> 
> 	for ( ; (((ch=getch()) < '1' || ch > '5') && ch != 'E') ; )
> 		putchar(BELL);
> 	addch(ch);
> 	refresh();
> 
How about this version
/* input characters until either "E" or a number between 1 and 5 is input */
	for (;;) {
		ch=getch();
		if ((ch>='1'&&ch<='5')||ch=='E') break;
		putchar(BELL);
	}
	addch(ch);
	refresh();

	Some people go to great lengths to get efficiency.  In doing
this they sometimes make there code more difficult to read.
	If a piece of code is difficult to read, then simplify it. There
are many ways of doing this other than putting in goto's.  Goto's should
be avoided accept when they simplify code THAT CAN't BE SIMPLIFIED some
other way.
Mike(always a dreamer) Wexler
15530 Rockfield, Building C
Irvine, Ca 92718
(714)855-3923
(trwrb|scgvaxd)!felix!peregrine!mike

-- 
Mike(always a dreamer) Wexler
15530 Rockfield, Building C
Irvine, Ca 92718
(714)855-3923
(trwrb|scgvaxd)!felix!peregrine!mike