I didn't say it can't already be done. However,
what if I want to iterate over something more complex than a
table+pairs dataset? The generic for loop is much more powerful
than that:
stat ::= for namelist in explist do block end
Any flavor of namelist/explist would require a "specialized
generalization" similar to what is described in chapter 3.3.5 of
the documentation, to extract the iterator function, for each
length of namelist. This would defeat what I am after: a simple
way of expressing my intent. I am not saying it's important,
just that it would help write expressive code in that kind of
situation without having to jump through hoops. After all, we
have the numerical for loop in the language:
stat ::= for Name ‘=’ exp ‘,’ exp [‘,’ exp] do block end
Is it important? Maybe not because Lua could offer a range
function to perform numerical loops like so, just like it offers
pairs()/next() to iterate over table contents:
for i in range(from,to,step) do
print(i)
end
However the numerical loop exists. (And yes, I understand
that I am the devil's advocate here, as the numerical loop
saves function calls, so it is beneficial for performance
reasons).
Anyway, no big deal. Either Lua authors think it's
worthwhile, or not. The most likely is that they already had
that idea on their own and decided against it, for reasons of
minimalism: don't do it if it's not needed, just like you
said. Time to stop the noise :-).
Benoit.