[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Question about 5.0 for loop
- From: Tom Wrensch <twrensch@...>
- Date: Thu, 6 Jun 2002 10:56:01 -0700 (PDT)
>- we changed the generic for, so that now it handles a state.
> for var_1, ..., var_n in explist do block end
> is equivalent to
> local _f, _s, var_1 = explist
> local var_2, ..., var_n
> while 1 do
> var_1, ..., var_n = _f(_s, var_1)
> if var_1 == nil then break end
I like the idea of some state information being passed around in the
function (though you can use a closure to do the same thing) but I don't
understand the equivalent code example above.
Presumibly _s is the state information, and is passed to the iteration
function as the first argument. But I don't see any way _s could ever be
modified--it starts out as nil and stays nil. I played with the
interpreter and am no closer to understanding how this works.
An answer of "wait until the documentation comes out" is okay :-).
- Tom Wrensch