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.

1
2
3
   loop {
      // statements
   }

The idea is that you only really need one loop statement, because it’s just a matter of using

1
if

and

1
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.

1
2
3
   for (;;) {
      // statements
   }

For example, a

1
while

loop is just:

1
2
3
4
   loop {
      if ( ! condition ) break;
      // statements
   }

A

1
do-while

is simply:

1
2
3
4
   loop {
      // statements
      if ( ! condition ) break;
   }

A C-style

1
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

1
for

statement to see when the condition is checked and when the increment happens. It does get a bit messy if you have a

1
continue

, since you have to remember to increment before you continue.

1
2
3
4
5
6
   [initializer]
   loop {
      if ( ! condition ) break;
      // statements
      [increment]
   }

The generic infinite loop isn’t a convenient replacement for the

1
foreach

constructs found in some modern languages, and in fact,

1
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

1
once

block. This would allow

1
break

statements, but no

1
continue

statements. Some of you will recognize this as the equivelent to the do-while-false idiom.

1
2
3
   once {
      // statements
   }

Conclusion

These constructs,

1
loop

and

1
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

1
loop

does accomplish is making good on the promise of making code easy to write, read, and understand.