lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 1/26/06, Lisa Parratt <> wrote:
> Mark Edgar wrote:
> > loop
> >   line =
> > while line
> >   io.write(line)
> > repeat
> Is that similar to Ada's:
> loop
>         exit when /condition/;
> end loop;
> ? It always struck me as an exceedingly beautiful way of making all the
> different sorts of loop disappear up themselves.

Not exactly.  In Ada, you can use exit-when- or just exit
in any of the `loop', `for', and `while' constructs.  But exit is not
a part of the syntax of any of these, so you don't have to use it.
Moreover, the exit can be nested in an `if', a block, or another
loop that is itself a part of the loop being exited.  In effect, exit
is nothing more than what the if-break is in C.
Forth's begin-while-repeat, on the other hand, is a true
n-and-a-half loop.