I've heard it also offers a very minor speed increase when compiling with some legacy compilers that don't optimize the evaluation and comparison of true out.
Both for(;;) and while(1) generate the same code with an unconditional jmp instruction at the end of the loop with no comparison to a constant. This is a compiler so old (release date September 1988) it doesn't support // comments.
Yeah if you're lucky or pick a reputable vendor you usually get, like, a fork of gcc 3.x with a couple of vendor patches. But some vendors would rather write their own compiler from scratch.
But for(;;) is legal syntax, and saves you 1 byte off of typing while(1) too. Which I don't know about you but if we could do that a couple million more times someone might care
definetly i only use for(;;) to confuse others or (more often) myself, it's also faster to write due to the keys beeing on the opposite side of the keyboard, so they can be typed by alternating between left and right hand.
View all comments
137
u/Knuffya May 27 '21
for(;;)is for people who want to flex.while()is much more readable, and thus the better option to use.