On 30-Aug-05, at 10:23 AM, Boyko Bantchev wrote:
That fails to declare i. Actually, I should have written the C line as follows:Sorry, just couldn't resist the following :) On 8/30/05, Rici Lake <lua@ricilake.net> wrote:int i; for (i = 1; i <= 10; ++i) { ... } for i = 1, 10 do ... end Advantage: Lua, 16 fewer keystrokesNot so. Having once defined #define DO(var,from,to) for (var=from; var<=to; ++var) then DO(i,1,10) {...}
{ int i; for (i = 1; i <= 10; ++i) { ... } }
You could actually write that as a macro in C9x, taking advantage of
the bizarre syntax for declaring control variables inside for
expressions. But afaik there is no way of doing that in C90.