lua-users home
lua-l archive

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


On ven. 04 oct. 2002 10:49:15, "Albert-Jan Brouwer" <acj.brouwer@citeng.com> 
wrote:

> The
> 
> for var_1, ..., var_n in explist do block end
> 
> syntax is documented to be equivalent to
> 
> do
>   local _f, _s, var_1 = explist
>   while 1 do
>     local var_2, ..., var_n
>     var_1, ...., var_n = _f(_s, var_1)
>     if var_1 == nil then break end
>     block
>   end
> end
> 
> I suppose the syntax was chosen with some
> convenient usage scenarios in mind. What
> are they? I have not been able to construct
> one that does not look convoluted.

Well, there was some discussion on this topic some time ago, as I was quite 
confused myself.
I finally created a Wiki page to summarize this discussion. http://lua-
users.org/wiki/NewFor

Perhaps you will find some more information from there. It is still a bit 
artificial, but at least more concrete than the pseudo-code...

-- 
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/