lua-users home
lua-l archive

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


On Tue, Feb 26, 2008 at 9:00 AM, Fabien <fleutot+lua@gmail.com> wrote:
> Since the regular rant about the missing "continue" statement resurfaced
> again, I thought I might point to an experiment I did, which covers most of
> the cases where I'd otherwise miss "continue":
>
> http://metalua.blogspot.com/2008/02/syntax-experiments.html
>
> Basically, it lets qualify a loop header with additional properties like
> "if", "while", "until", "for". Many "break"s in for loops can be replaced
> with:
>
>     for k, v in pairs(some_table) until leaving_condition do
>        ...
>      end
>
>     for i=1, 10 while not_leaving do
>         ...
>     end
>
> and most "continue" statements can be replaced with:
>
>     for k, v in pairs(some_table) if not some_reason_to_skip do
>         ...
>     end
>

Why syntaxize it? Just have a function which wraps an iterator and a
(probably anonymous) function and produces a filtered iterator.

Ben