The Answer to Infinite Loops

Programmers, we should make our infinite loops more exciting! A lot of times in C or other languages, you see infinite loops represented by things such as

while (1) { /* do stuff here */ }

Or perhaps by

for (;;) { /* do stuff here */ }

Thats so boring! Why not be more creative in your work? I propose that we use the following construct instead

while (42) { /* do stuff here */ }

Now you might ask, why use while() instead of for() or do.. while()? In my opinion, its cleaner (the while part, not necessarily the number part). while() seems like the correct options, since (in my mind, at least) for() implies some set amount of iteration, whereas while() implies keep going until some condition is false. Of course, I do realize that they all do the same thing and each different one can do the same things as the others with some modification.

Yes, that was a rather useless post, but I had to get it off of my chest 🙂

This entry was posted
on Sunday, June 29th, 2008 at 1:10 am and is filed under General.
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.

3 Responses to “The Answer to Infinite Loops”

I agree that while is more clear than for, but why is while(42) more clear than while(1). yes, 42 is an important number which I have engraved on my towel, but while(42) is probably still likely to confuse the noobs. (As in “Why the heck”)
It’s perfect for analogies though, like:
while(42){live_life();}
exit(0);

I edited the post a little bit, the while() part is cleaner, not the number part. And yes, it will probably confuse the n00bs, but they will learn an important lesson from it — 1 isn’t the only true number. :p