tags:

views:

182

answers:

3
+2  A: 

There is no advantage to for(;;) over while(1). Use while(1), because it's easier to comprehend (imho). I've never seen a for(;;) used before, and it may be confusing to others who view your code, and may wonder the same thing you just asked.

EDIT: Here's a link: http://stackoverflow.com/questions/885908/while-1-vs-for-is-there-a-speed-difference

It basically says that they both generate the same code. In assembly, it's jmp ....

muntoo
+5  A: 

I personally prefer using while(2!=3){...} :-)

Zhenya
@Zhenya - I think while(true == true )
slomojo
@slomojo: that's too wordy to my tastes ;-)
Zhenya
Oh, it's funny because they're all `true`!
Adam Robinson
Or how about `for(byte x = 128; x++; x--)`
muntoo
How about `while (!0 ^ !1) {...}`?
Marcelo Cantos
`for(for(;0;);;for(;0;))`
muntoo
Personally i prever `while("forever"){...}`
Johannes Schaub - litb
+1  A: 

Less typing? It's shorter. And on a QWERTY keyboard, typing for alternates between the left and right hand, and while has three consecutive letters that are typed with the right hand, making typing it potentially even slower.

Ori Pessach
What is it about C programmers and idiot levels of micro-optimizations? If you're focusing on the speed of your typing, you're doing programming wrong.
JUST MY correct OPINION
@JUST MY correct OPINION: Whoosh...
Ori Pessach
@Ori Pessach: While you may be (and probably are) joking, I have heard this kind of foolishness before. Vi/m advocates use this kind of reasoning for evangelizing Vi/m, for example, and I have heard from more than a few C programmers that they can't stand the Wirthian family of languages (Pascal, the Modulas, the Oberons, Ada etc.) because it takes too much effort to type `BEGIN ... END` over `{ ... }`. Can you forgive me for confusing your joke with these very tragic realities? ;)
JUST MY correct OPINION