[comp.lang.forth] Other interpreted control structures

wmb@SUN.COM (Mitch Bradley) (12/30/89)

Here's a control structure that Don Hopkins and I came up with while
were were doing a Forth command language for a schematic drawing system.
This control structure combines the functions of FOR .. NEXT  and
IF .. ELSE .. THEN  in a convenient way:

   n  [  ... body ...  ]

  \ body is execute n times if n > 0

   n  [  ... body ...  ][  ... else ...  ]

  \ Body is executed n times if n > 0, otherwise else clause
  \ is executed

This is equivalent to IF ... ELSE ... THEN  if n is 0 or 1

We found this syntax to be very pleasant for interactive use.

The use of brackets for control structures is reminiscent of LaFarr
Stewart's LaForth system.

Mitch