C style
tp at ndm20
tp at ndm20
Tue Sep 24 10:05:00 AEST 1985
>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 of us feel the same about breaks as we do about gotos. I won't use it, or
continue either, and I won't let anyone in my shop use it. It is just a goto
with an implicit label, and destroys the ability to determine program flow from
the FORM of the source even more drastically, as there is no label to catch
your eye and alert you to the presence of the d*mned thing. The only way I will
use a break is in a set of macros implementing a middle exit loop construct.
We use LOOP...LOOPUNTIL...ENDLOOP. I know, adding features to a language with
#define has problems, but at least that code is readable once you know what the
constructs do, which is quite apparent. C should have that structure built in.
Since it doesn't, we add it. The keywords are at the same indentation level, of
course.
Thanks,
Terry Poot
Nathan D. Maier Consulting Engineers
(214)739-4741
Usenet: ...!{allegra|ihnp4}!convex!smu!ndm20!tp
CSNET: ndm20!tp at smu
ARPA: ndm20!tp%smu at csnet-relay.ARPA
(-: Someone challenged me to produce flames. This should do it :-)
More information about the Comp.lang.c
mailing list