The next revision of the Slick-C language is introducing a new infinite loop statement. It is a concept borrowed from Modula and Wirth’s Oberon, and probably several other languages.

   loop { 
      // statements 
   } 

The idea is that you only really need one loop statement, because it’s just a matter of using if and break in the right spots. It is completely identical to the common C/C++ idiom below, just a little more obvious to the novice coder.

   for (;;) { 
      // statements 
   } 

For example, a while loop is just:

   loop { 
      if ( ! condition ) break; 
      // statements 
   } 

A do-while is simply:

   loop { 
      // statements 
      if ( ! condition ) break; 
   } 

A C-style for loop is more complex to code, but one could argue, quite a bit easier for the uninitiated programmer to read and understand, because you don’t have to know anything about the semantics of a for statement to see when the condition is checked and when the increment happens. It does get a bit messy if you have a continue, since you have to remember to increment before you continue.

   [initializer] 
   loop { 
      if ( ! condition ) break; 
      // statements 
      [increment] 
   } 

The generic infinite loop isn’t a convenient replacement for the foreach constructs found in some modern languages, and in fact, loop is not a great replacement for the counter-based for loops found in older languages such as Pascal and Cobol.

While Slick-C can never abandon traditional looping constructs entirely, this does give you a glimpse of what a truly bare-bones language could do. In fact, such a language could go one step further, and introduce a once block. This would allow break statements, but no continue statements. Some of you will recognize this as the equivelent to the do-while-false idiom.

   once { 
      // statements 
   } 

Conclusion

These constructs, loop and once are no advancements in the state of the art, they are just alternate, simpler ways to write code. Novice coders will welcome the simplicity. Experienced programmers will shrug it off as just another way to do the same thing they have been doing for decades, and are likely to even complain that it introduces more complexity since it is yet another new statement type. What loop does accomplish is making good on the promise of making code easy to write, read, and understand.