C Style

Stanley Friesen friesen at psivax.UUCP
Tue Sep 17 02:35:31 AEST 1985


In article <180 at chinet.UUCP> rlk at 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 at rand-unix.arpa



More information about the Comp.lang.c mailing list