lua-users home
lua-l archive

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


> example 1:

> for ... do
>  if c1 then do
>    ...
>    if c2 then do
>      ...
>      if c3 then do
>        ...
>        if c4 then do
>          ...
>          if c5 then do
>            ...
>            if c6 then do
>              ...
>            end
>          end
>        end
>      end
>    end
>  end
> end

> example 2:

> for ... do
>  if not c1 then do continue end
>  ...
>  if not c2 then do continue end
>  ...
>  if not c3 then do continue end
>  ...
>  if not c4 then do continue end
>  ...
>  if not c5 then do continue end
>  ...
>  if not c6 then do continue end
> end

> which example is more clean and more elegant looking? yep, the second one
> is.

I'd say neither are clean and elegant looking. Such complex loop
bodies are to be refactored. If you can't refactor it to a set of
functions due to performance considerations, then elegance should not
be issue.

Alexander.