Infinite loops

Roe Peterson roe at toram.UUCP
Tue Apr 22 02:07:39 AEST 1986


In article <577 at ur-helheim.UUCP> badri at ur-helheim.UUCP (Badri Lokanathan) writes:
>My question is the following: is there any reason (other
>than personal preferance) why one would prefer to use any particular form?
>I personally prefer the while(1) form since it seems to make better reading.
>Even better, I sometimes define TRUE to be 1 and then use while(TRUE).

Unless you have a very unique optimizer, it is usually better to use the
for(;;) form rather than the while(1) form.  Reason is:  while(1) is
ALWAYS evaluated (ie. : is 1 TRUE? if so, continue) before each iteration,
whereas for(;;) compiles as a simple branch or jump instruction with no
test and no conditional branch.

simply loops with no checks.


-- 

				Roe Peterson
				{linus,ihnp4,decvax}!utzoo!toram!roe

				All that glitters is spray-paint.



More information about the Comp.lang.c mailing list