[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: hpairs?
- From: Steve Litt <slitt@...>
- Date: Tue, 28 Dec 2010 22:52:26 -0500
On Tuesday 28 December 2010 17:52:19 Doug Currie wrote:
> 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
Thanks Doug,
Before your help I couldn't make heads nor tails of this syntax. Even after
your help, it still took me 45 minutes to understand this thing, but in the
end I understood the generic for statement much better, so thank you very
much.
Steve
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt