I am working with Lua 5.0, what puzzles me is why the following code works:
for i in {first=1,second=2,third=3} do
print(i)
end
It prints 'first', 'second', 'third'. However, according to the online programming in Lua for 5.0 "The first thing the for does is to evaluate the expressions after the in. These expressions should result in the three values kept by the for: the iterator function, the invariant state, and the initial value for the control variable."
In this case, the expression after the in is simply a table. It won't evaluate into (function, state, initial value), and any subsequent call would be a call to the table itself. But the above example works, why?