Infinite loops
aglew at ccvaxa.UUCP
aglew at ccvaxa.UUCP
Sat Apr 19 10:46:00 AEST 1986
while(1){} vs. for(;;)
you forgot to mention do{}while(1);
take a look at the code your compiler produces for each one. a good
optimizing compiler should make them all the same, but not all compilers are
good optimizing compilers. i fell into the habit of using while(1) on
68000s; when i started working on 80x86s i found that for(;;) was faster.
i have therefore put
#if defined(MPU68000)
# define loop while(1)
#elif defined(MPU8086) || defined(MPU80286)
# define loop for(;;)
#endif
into my personal header. if do{}while(1) proved faster then I suppose I
would have to put an endloop in.
My favorites are
#define the_sky_is_blue 1
while(the_sky_is_blue){}
and
#define ever_and_a_day ;;
for(ever_and_a_day){}
or, in Pascal
CONST Hell_freezes_over = TRUE;
REPEAT ... UNTIL Hell_freezes_over;
But my boss gets angry enough at me as it is! (are you there, Gary?)
Andy "Krazy" Glew. Gould CSD-Urbana. USEnet: ihnp4!uiucdcs!ccvaxa!aglew
1101 E. University, Urbana, IL 61801 ARPAnet: aglew at gswd-vms
More information about the Comp.lang.c
mailing list