lua-users home
lua-l archive

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


>>>>> "Luiz" == Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:

    Luiz> We'd like your opinion on whether we should add a FOR loop to
    Luiz> Lua:

    Luiz> 1. Do you miss FOR loops?  2. What syntax would you suggest?

Yes, I miss for loops. The syntax that I would find most useful is

t={1,2,3,'eww'}
for elt in t do
	do_whatever(elf)
end

This is not the most general 'for' you can think of, but this is what I do
most of the time: go through a table and look at each element. Sure, you
can do it using next etc, but this would be much less hassle.

M.