Here are a few code examples to keep you busy:

C:
while (1); // Just sitting around, spinning.
sh/bash/ash/ksh:
while true; do true; done
perl:
while (1) {
    # sit 'n spin
}
tcl:
while { 1 } {
    # Also sit and spin.
}

 

The Unbelievably Technically Advanced Everything Endless Loop

Basic:
10 REM Hunt down and brutaly murder CPU cycles!
20 GOTO 10
Strictly speaking, an endless loop dosen't need to be in code. They're just rather diffucult to find in real life. (People don't tend, for instance, to drive around in a circle FOREVER.)
Some more interesting ones in C:

  for(;;){
     /*Yee ha!*/
  }


/*Call me for a good time!
 * I have the added advantage of making your stack huge!*/
void blar (void) {
  /*MoreFun!*/
  blar();
}

I'll write some more if I get bored again. *grin*
Oh, yeah. Feel free to throw in a fork() if you want to bring your machine to its knees fairly quickly. *evilgrin

If you've got to do nothing in Perl, why not do it the stylish way? Pick one of these loopy ideas:

  1. 1 while 1 (or 0 until 0)
  2. {redo}
  3. Of course for(;;){} also works, but is boring.

Log in or register to write something here or to contact authors.