lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

>- 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
>        do
>          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
>            block
>          end
>        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