It's not my intention to overcomplicate a simple mechanism, what I want is a mechanism that broad enough to cover several use cases and not just a single one.And "in" is the keyword it should be, if this would be "from", then it would be "from" in the for loop as well.Of course, that was Luiz' comment as well. But beware of overcomplicating a simple mechanism.....
for var_1, ···, var_n in explist do block end
is equivalent to the code:
do local f, s, var = explist while true do local var_1, ···, var_n = f(s, var) if var_1 == nil then break end var = var_1 block end end
var_1, ···, var_n = varname_1, varname_2 ... varname_n in explist
is equivalent to the code:
local f, s = explist local var_1, ···, var_n = f(s, "varname_1"), f(s, "varname_2") ... f(s, "varname_n")Were "varname_1" means that this literal is passed as a string to the function. The idea here is that f is an "indexer" function instead of a iterator function.
> personally I'd find it cool if the "in X" could also point to a string literal which is required.I don't really like to get "require" getting involved here. IMO the "in" statement should simplify the assignment of many locals from a function or table.
-- Thomas