Pascal (was Re: for(;;) vs. while(1) is a draw)
e89hse at rigel.efd.lth.se
e89hse at rigel.efd.lth.se
Mon Jun 4 02:14:09 AEST 1990
In article <3928 at darkstar.ucsc.edu>, femto at ucscb.UCSC.EDU (71017000) writes:
>
>I have used the following for several years:
>
>#define HELL 666
>#define FROZEN -273
>
>while (HELL != FROZEN) {
> ... do whatever
I think it would be better to write something like:
#if HELL != FROZEN
for(;;) /* or while(1) if you prefer */
... do whatever
#endif
This has the advatge that lint (at least some lints) won't warn you for
unreachable code. I also think, but this is a personal opinion, that it is
clearer.
Henrik Sandell
ps. Concerning while(1) and for(;;). My old CP/m C-compiler (Digital Research)
used to have the declaration:
#define forever() for(;;)
in portab.h. I agree that for(;;) is ugly, but somehow I don't think while(1)
look good either.
More information about the Comp.lang.c
mailing list