lua-users home
lua-l archive

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


I've been thinking it would be nice to have another form of the for loop on
top of two we have now, for iterating lists:

    for val in list do
        print(val)
    end

The equivalent in the Lua as it is now:

    for i = 1, getn(list) do
        local val = list[i]
        print(val)
    end

Such iteration (where the list is not modified) is very common.  My argument
for adding this new form is that it's more terse, less error prone
(forgetting the local qualifier, etc), and faster if the list happens to be
a global.

Any thoughts?

-John