[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: list iteration for statement
- From: "John Belmonte" <jvb@...>
- Date: Thu, 26 Apr 2001 18:15:30 +0900
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