[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: hpairs?
- From: Doug Currie <doug.currie@...>
- Date: Tue, 28 Dec 2010 17:52:19 -0500
On Dec 28, 2010, at 5:31 PM, Steve Litt wrote:
> And the same documentation shows the generic for statement as:
>
> for var_1, ···, var_n in explist do block end
>
> explist is supposed to be an iterator function.
No, it's "an iterator function, a state, and an initial value for the first iterator variable."
> I have no idea how "next, t,
> #t > 0 and #t or nil" evaluates to an iterator function.
next is the iterator function
t is the state
#t > 0 and #t or nil is the initial value for the first iterator variable
How these are used by the generic for statement is described in the pseudo code at
http://www.lua.org/manual/5.1/manual.html#2.4.5
e