lua-users home
lua-l archive

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


2014-06-27 12:30 GMT+02:00 Paige DePol <lual@serfnet.org>:
>> - and that it would be possible use the same mechanism to add the
>> constructions "continue", "resume" and "restart" to loops, although
>> spelling them "goto continue", "goto resume" and "goto restart",
>
> I get `continue` and `restart`, but what would `resume` do?

Take the following situation: you have a lot of items in a table
and process them. Processing involves an initial quick-and-dirty
method, during which

- you may finish an item (move it out of the table and continue),
- discover that the goal has been achieved (break),
- find that you need to add another item (restart the loop,
since `next` is invalidated),
- or none of these.

You now apply a more expensive method of processing,
which could result in bringing the item into a state where
the original method might work (resume, i.e. go back to
the start of the loop with the current item).